Skip to content

Commit

Permalink
[media] zr364xx: enforce minimum size when reading header
Browse files Browse the repository at this point in the history
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>
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Alyssa Milburn authored and Mauro Carvalho Chehab committed Apr 18, 2017
1 parent 821117d commit ee0fe83
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/media/usb/zr364xx/zr364xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ static int zr364xx_read_video_callback(struct zr364xx_camera *cam,
ptr = pdest = frm->lpvbits;

if (frm->ulState == ZR364XX_READ_IDLE) {
if (purb->actual_length < 128) {
/* header incomplete */
dev_info(&cam->udev->dev,
"%s: buffer (%d bytes) too small to hold jpeg header. Discarding.\n",
__func__, purb->actual_length);
return -EINVAL;
}

frm->ulState = ZR364XX_READ_FRAME;
frm->cur_size = 0;

Expand Down

0 comments on commit ee0fe83

Please sign in to comment.