Skip to content

Commit 2389a65

Browse files
seanyoungbwhacks
authored andcommitted
media: technisat-usb2: break out of loop at end of buffer
commit 0c4df39 upstream. Ensure we do not access the buffer beyond the end if no 0xff byte is encountered. Reported-by: [email protected] Signed-off-by: Sean Young <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> [bwh: Backported to 3.16: technisat_usb2_get_ir() still uses a stack buffer, which is not worth fixing on this branch] Signed-off-by: Ben Hutchings <[email protected]>
1 parent 4accfbf commit 2389a65

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

drivers/media/usb/dvb-usb/technisat-usb2.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
591591

592592
static int technisat_usb2_get_ir(struct dvb_usb_device *d)
593593
{
594-
u8 buf[62], *b;
595-
int ret;
596594
struct ir_raw_event ev;
595+
u8 buf[62];
596+
int i, ret;
597597

598598
buf[0] = GET_IR_DATA_VENDOR_REQUEST;
599599
buf[1] = 0x08;
@@ -629,26 +629,25 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
629629
return 0; /* no key pressed */
630630

631631
/* decoding */
632-
b = buf+1;
633632

634633
#if 0
635634
deb_rc("RC: %d ", ret);
636-
debug_dump(b, ret, deb_rc);
635+
debug_dump(buf + 1, ret, deb_rc);
637636
#endif
638637

639638
ev.pulse = 0;
640-
while (1) {
641-
ev.pulse = !ev.pulse;
642-
ev.duration = (*b * FIRMWARE_CLOCK_DIVISOR * FIRMWARE_CLOCK_TICK) / 1000;
643-
ir_raw_event_store(d->rc_dev, &ev);
644-
645-
b++;
646-
if (*b == 0xff) {
639+
for (i = 1; i < ARRAY_SIZE(buf); i++) {
640+
if (buf[i] == 0xff) {
647641
ev.pulse = 0;
648642
ev.duration = 888888*2;
649643
ir_raw_event_store(d->rc_dev, &ev);
650644
break;
651645
}
646+
647+
ev.pulse = !ev.pulse;
648+
ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR *
649+
FIRMWARE_CLOCK_TICK) / 1000;
650+
ir_raw_event_store(d->rc_dev, &ev);
652651
}
653652

654653
ir_raw_event_handle(d->rc_dev);

0 commit comments

Comments
 (0)