Skip to content

Commit e5a9ebb

Browse files
noopwafelgregkh
authored andcommitted
zr364xx: enforce minimum size when reading header
commit ee0fe833d96793853335844b6d99fb76bd12cbeb upstream. This code copies actual_length-128 bytes from the header, which will underflow if the received buffer is too small. Signed-off-by: Alyssa Milburn <amilburn@zall.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a6e0caa commit e5a9ebb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/media/usb/zr364xx/zr364xx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,14 @@ static int zr364xx_read_video_callback(struct zr364xx_camera *cam,
604604
ptr = pdest = frm->lpvbits;
605605

606606
if (frm->ulState == ZR364XX_READ_IDLE) {
607+
if (purb->actual_length < 128) {
608+
/* header incomplete */
609+
dev_info(&cam->udev->dev,
610+
"%s: buffer (%d bytes) too small to hold jpeg header. Discarding.\n",
611+
__func__, purb->actual_length);
612+
return -EINVAL;
613+
}
614+
607615
frm->ulState = ZR364XX_READ_FRAME;
608616
frm->cur_size = 0;
609617

0 commit comments

Comments
 (0)