Commit e674844a authored by Alyssa Milburn's avatar Alyssa Milburn Committed by Ben Hutchings

zr364xx: enforce minimum size when reading header

commit ee0fe833 upstream.

This code copies actual_length-128 bytes from the header, which will
underflow if the received buffer is too small.
Signed-off-by: default avatarAlyssa Milburn <amilburn@zall.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 1a4b6a9a
......@@ -611,6 +611,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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment