Skip to content

Commit

Permalink
[media] dvb-usb: check for invalid length in ttusb_process_muxpack()
Browse files Browse the repository at this point in the history
This patch is driven by a static checker warning.
The ttusb_process_muxpack() function is only called from
ttusb_process_frame().  Before calling, it verifies that len >= 2.  The
problem is that len == 2 is not valid and would lead to an array
underflow.
Odd number values for len are also invalid and would lead to reading
past the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Feb 8, 2013
1 parent 3e58ac1 commit bf5bbed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,13 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
{
u16 csum = 0, cc;
int i;

if (len < 4 || len & 0x1) {
pr_warn("%s: muxpack has invalid len %d\n", __func__, len);
numinvalid++;
return;
}

for (i = 0; i < len; i += 2)
csum ^= le16_to_cpup((__le16 *) (muxpack + i));
if (csum) {
Expand Down

0 comments on commit bf5bbed

Please sign in to comment.