mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
uvideo: fix step=0 infinite loop and int overflow in fbuf_size
Prevent infinite loop in uvideo_vs_negotiation() when a USB camera reports step=0 in its continuous frame interval descriptor. Cast fbuf_size calculation to uint64_t to avoid int overflow for large width/height/bpp combinations. Reported by: emaste
This commit is contained in:
1 parent
26bb78b772
commit
8468152509
1 file changed
+3
-1
@@ -1744,7 +1744,7 @@ uvideo_vs_parse_desc_frame_buffer_size(struct uvideo_softc *sc,
|
||||
* width * height * bpp since dwMaxVideoFrameBufferSize may be wrong.
|
||||
*/
|
||||
if (desc->bDescriptorSubtype == UDESCSUB_VS_FRAME_UNCOMPRESSED) {
|
||||
fbuf_size = UGETW(fd->u.uc.wWidth) *
|
||||
fbuf_size = (uint64_t)UGETW(fd->u.uc.wWidth) *
|
||||
UGETW(fd->u.uc.wHeight) *
|
||||
sc->sc_fmtgrp[fmtidx].format->u.uc.bBitsPerPixel / NBBY;
|
||||
} else
|
||||
@@ -2037,6 +2037,8 @@ uvideo_vs_negotiation(struct uvideo_softc *sc, int commit)
|
||||
else if (frame_ival >= max)
|
||||
frame_ival = max;
|
||||
else {
|
||||
if (step == 0)
|
||||
step = 1;
|
||||
for (i = min;
|
||||
i + step / 2 < frame_ival;
|
||||
i += step)
|
||||
|
||||
Reference in new issue
Block a user