]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
V4L: uvcvideo: Fix a buffer overflow in format descriptor parsing
authorLaurent Pinchart <laurent.pinchart@skynet.be>
Tue, 22 Jul 2008 01:53:45 +0000 (21:53 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 1 Aug 2008 19:43:08 +0000 (12:43 -0700)
(cherry picked from commit 233548a2fd934a0220db8b1521c0bc88c82e5e53)

V4L: uvcvideo: Fix a buffer overflow in format descriptor parsing

Thanks to Oliver Neukum for catching and reporting this bug.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/media/video/uvc/uvc_driver.c

index 60ced589f89815d84de454fffb2e1cd6916bf4bd..86bb16d001730a61b51776ab48130ae210d16036 100644 (file)
@@ -298,7 +298,8 @@ static int uvc_parse_format(struct uvc_device *dev,
        switch (buffer[2]) {
        case VS_FORMAT_UNCOMPRESSED:
        case VS_FORMAT_FRAME_BASED:
-               if (buflen < 27) {
+               n = buffer[2] == VS_FORMAT_UNCOMPRESSED ? 27 : 28;
+               if (buflen < n) {
                        uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming"
                               "interface %d FORMAT error\n",
                               dev->udev->devnum,