summaryrefslogtreecommitdiff
path: root/sys/dev/usb/uvideo.c
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2008-08-02 12:32:24 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2008-08-02 12:32:24 +0000
commit3724e74926cb889f1b439e8214da02c3c6ed863a (patch)
treeb2e6c077a64ad4d6abdd0b002d4c1c5c27fa6f44 /sys/dev/usb/uvideo.c
parent2cf37e5f70caff92795a6781a03bee6633b2870a (diff)
If a format descriptor doesn't contain any frame descriptors even if it
claims to (as seen on the M$ LifeCam NX6000), abort further processing. Safes us from potential NULL pointer derefs.
Diffstat (limited to 'sys/dev/usb/uvideo.c')
-rw-r--r--sys/dev/usb/uvideo.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 7230049724f..b9ce5afaea7 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.69 2008/08/02 08:51:25 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.70 2008/08/02 12:32:23 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -1032,6 +1032,13 @@ uvideo_vs_negotiation(struct uvideo_softc *sc, int commit)
pc = (struct usb_video_probe_commit *)probe_data;
+ /* check if the format descriptor contains frame descriptors */
+ if (sc->sc_fmtgrp_cur->frame_num == 0) {
+ printf("%s: %s: no frame descriptors found!\n",
+ __func__, DEVNAME(sc));
+ return (USBD_INVAL);
+ }
+
/* get probe */
bzero(probe_data, sizeof(probe_data));
error = uvideo_vs_get_probe(sc, probe_data, GET_DEF);
@@ -2188,6 +2195,13 @@ uvideo_s_fmt(void *v, struct v4l2_format *fmt)
if (found == 0)
return (EINVAL);
+ /* check if the format descriptor contains frame descriptors */
+ if (sc->sc_fmtgrp[i].frame_num == 0) {
+ printf("%s: %s: no frame descriptors found!\n",
+ __func__, DEVNAME(sc));
+ return (EINVAL);
+ }
+
/* search requested frame resolution */
uvideo_find_res(sc, i, fmt->fmt.pix.width, fmt->fmt.pix.height, &r);