aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn <amilburn@zall.org>2017-04-01 14:34:08 -0300
committerSasha Levin <alexander.levin@verizon.com>2017-05-17 15:08:23 -0400
commit1ff629068e6e0fe2270272e3976eefef00fa5cc7 (patch)
treee8fd1231911ba8598fad96094ac1e807ca18e8d9
parenta0f82864854a4511cd19f06436f0cf140fae2427 (diff)
[media] zr364xx: enforce minimum size when reading header
[ Upstream commit ee0fe833d96793853335844b6d99fb76bd12cbeb ] 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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index ca850316d379..63a603b41b7e 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -605,6 +605,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;