[patch 2/2]: firedtv: use length_field() of PMT as length

Henrik Kurelid henke at kurelid.se
Fri Dec 5 09:48:31 UTC 2008


>From 750daa3bccae26cde9806dad3b4b81eb9baa81c7 Mon Sep 17 00:00:00 2001
From: Henrik Kurelid <henrik at kurelid.se>
Date: Fri, 5 Dec 2008 10:00:16 +0100
Subject: [PATCH] firedtv: use length_field() of PMT as length

Parsed and used the length_field() of the PMT mesage instead of using
the length field of the message struct, which does not seem to be
filled correctly by e.g. MythTV.

Signed-off-by: Henrik Kurelid <henrik at kurelid.se>
---
 drivers/media/dvb/firesat/firesat-ci.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/firesat/firesat-ci.c b/drivers/media/dvb/firesat/firesat-ci.c
index 0deb47e..b4ac414 100644
--- a/drivers/media/dvb/firesat/firesat-ci.c
+++ b/drivers/media/dvb/firesat/firesat-ci.c
@@ -127,14 +127,22 @@ static int firesat_ca_pmt(struct firesat *firesat, void *arg)
 {
 	struct ca_msg *msg = arg;
 	int data_pos;
-
-	if (msg->msg[3] & 0x80)
-		data_pos = (msg->msg[4] && 0x7F) + 4;
-	else
-		data_pos = 4;
+	int data_length;
+	int i;
+
+	data_pos = 4;
+	if (msg->msg[3] & 0x80) {
+		data_length = 0;
+		for (i = 0; i < (msg->msg[3] & 0x7F); i++) {
+			data_length = (data_length << 8) + msg->msg[data_pos++];
+		}
+	}
+	else {
+		data_length = msg->msg[3];
+	}

 	return avc_ca_pmt(firesat, &msg->msg[data_pos],
-			  msg->length - data_pos) ? -EFAULT : 0;
+			  data_length) ? -EFAULT : 0;
 }

 static int firesat_ca_send_msg(struct firesat *firesat, void *arg)
-- 
1.5.4.3




More information about the devel mailing list