summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAlyssa Milburn <amilburn@zall.org>2017-04-01 13:34:08 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-04-18 11:57:29 -0400
commitee0fe833d96793853335844b6d99fb76bd12cbeb (patch)
tree9269034ee5ce117cbb6c6119226320e28d9cbf6a /drivers/media
parent821117dc21083a99dd99174c10848d70ff43de29 (diff)
[media] zr364xx: enforce minimum size when reading header
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>
Diffstat (limited to 'drivers/media')
-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 f2d6fc03dda0..efdcd5bd6a4c 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -600,6 +600,14 @@ static int zr364xx_read_video_callback(struct zr364xx_camera *cam,
600 ptr = pdest = frm->lpvbits; 600 ptr = pdest = frm->lpvbits;
601 601
602 if (frm->ulState == ZR364XX_READ_IDLE) { 602 if (frm->ulState == ZR364XX_READ_IDLE) {
603 if (purb->actual_length < 128) {
604 /* header incomplete */
605 dev_info(&cam->udev->dev,
606 "%s: buffer (%d bytes) too small to hold jpeg header. Discarding.\n",
607 __func__, purb->actual_length);
608 return -EINVAL;
609 }
610
603 frm->ulState = ZR364XX_READ_FRAME; 611 frm->ulState = ZR364XX_READ_FRAME;
604 frm->cur_size = 0; 612 frm->cur_size = 0;
605 613