Skip to content

Commit 0c4df39

Browse files
seanyoungmchehab
authored andcommitted
media: technisat-usb2: break out of loop at end of buffer
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]>
1 parent 5dd4b89 commit 0c4df39

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
608608
static int technisat_usb2_get_ir(struct dvb_usb_device *d)
609609
{
610610
struct technisat_usb2_state *state = d->priv;
611-
u8 *buf = state->buf;
612-
u8 *b;
613-
int ret;
614611
struct ir_raw_event ev;
612+
u8 *buf = state->buf;
613+
int i, ret;
615614

616615
buf[0] = GET_IR_DATA_VENDOR_REQUEST;
617616
buf[1] = 0x08;
@@ -647,26 +646,25 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
647646
return 0; /* no key pressed */
648647

649648
/* decoding */
650-
b = buf+1;
651649

652650
#if 0
653651
deb_rc("RC: %d ", ret);
654-
debug_dump(b, ret, deb_rc);
652+
debug_dump(buf + 1, ret, deb_rc);
655653
#endif
656654

657655
ev.pulse = 0;
658-
while (1) {
659-
ev.pulse = !ev.pulse;
660-
ev.duration = (*b * FIRMWARE_CLOCK_DIVISOR * FIRMWARE_CLOCK_TICK) / 1000;
661-
ir_raw_event_store(d->rc_dev, &ev);
662-
663-
b++;
664-
if (*b == 0xff) {
656+
for (i = 1; i < ARRAY_SIZE(state->buf); i++) {
657+
if (buf[i] == 0xff) {
665658
ev.pulse = 0;
666659
ev.duration = 888888*2;
667660
ir_raw_event_store(d->rc_dev, &ev);
668661
break;
669662
}
663+
664+
ev.pulse = !ev.pulse;
665+
ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR *
666+
FIRMWARE_CLOCK_TICK) / 1000;
667+
ir_raw_event_store(d->rc_dev, &ev);
670668
}
671669

672670
ir_raw_event_handle(d->rc_dev);

0 commit comments

Comments
 (0)