Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124165
b: refs/heads/master
c: c9535db
h: refs/heads/master
i:
  124163: 6c8941e
v: v3
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Dec 29, 2008
1 parent b3fd367 commit f6f8114
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f38483bc45e11dc138cedce72135f57819f57c4
refs/heads/master: c9535db3d23c56db50fe4e65542bf1c7f0a4681c
25 changes: 22 additions & 3 deletions trunk/drivers/media/video/uvc/uvc_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ static int uvc_parse_format(struct uvc_device *dev,
struct uvc_format_desc *fmtdesc;
struct uvc_frame *frame;
const unsigned char *start = buffer;
unsigned char *_buffer;
unsigned int interval;
unsigned int i, n;
int _buflen;
__u8 ftype;

format->type = buffer[2];
Expand Down Expand Up @@ -410,12 +412,20 @@ static int uvc_parse_format(struct uvc_device *dev,
buflen -= buffer[0];
buffer += buffer[0];

/* Count the number of frame descriptors to test the bFrameIndex
* field when parsing the descriptors. We can't rely on the
* bNumFrameDescriptors field as some cameras don't initialize it
* properly.
*/
for (_buflen = buflen, _buffer = buffer;
_buflen > 2 && _buffer[2] == ftype;
_buflen -= _buffer[0], _buffer += _buffer[0])
format->nframes++;

/* Parse the frame descriptors. Only uncompressed, MJPEG and frame
* based formats have frame descriptors.
*/
while (buflen > 2 && buffer[2] == ftype) {
frame = &format->frame[format->nframes];

if (ftype != VS_FRAME_FRAME_BASED)
n = buflen > 25 ? buffer[25] : 0;
else
Expand All @@ -430,6 +440,16 @@ static int uvc_parse_format(struct uvc_device *dev,
return -EINVAL;
}

if (buffer[3] - 1 >= format->nframes) {
uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming"
"interface %d frame index %u out of range\n",
dev->udev->devnum, alts->desc.bInterfaceNumber,
buffer[3]);
return -EINVAL;
}

frame = &format->frame[buffer[3] - 1];

frame->bFrameIndex = buffer[3];
frame->bmCapabilities = buffer[4];
frame->wWidth = le16_to_cpup((__le16 *)&buffer[5]);
Expand Down Expand Up @@ -486,7 +506,6 @@ static int uvc_parse_format(struct uvc_device *dev,
10000000/frame->dwDefaultFrameInterval,
(100000000/frame->dwDefaultFrameInterval)%10);

format->nframes++;
buflen -= buffer[0];
buffer += buffer[0];
}
Expand Down

0 comments on commit f6f8114

Please sign in to comment.