diff -Naur ivtv-0.3.7k.orig/driver/ivtv-controls.c ivtv-0.3.7k/driver/ivtv-controls.c --- ivtv-0.3.7k.orig/driver/ivtv-controls.c 2005-08-16 13:31:30 +0200 +++ ivtv-0.3.7k/driver/ivtv-controls.c 2005-09-11 06:49:45 +0200 @@ -26,7 +26,7 @@ static int ivtv_querymenu(struct v4l2_querymenu *qmenu) { const char **menu; - u32 i = qmenu->index;; + u32 menumax = 0; switch (qmenu->id) { case V4L2_CID_IVTV_FREQ:{ @@ -34,9 +34,9 @@ "44.1 kHz", "48 kHz", "32 kHz", - NULL }; menu = menu_freq; + menumax = sizeof(menu_freq) / sizeof(menu_freq[0]); break; } case V4L2_CID_IVTV_ENC:{ @@ -44,9 +44,9 @@ "Layer 1", "Layer 2", "Layer 3 (?)", - NULL }; menu = menu_layer; + menumax = sizeof(menu_layer) / sizeof(menu_layer[0]); break; } case V4L2_CID_IVTV_BITRATE:{ @@ -66,9 +66,9 @@ "[L1/L2] 384k/256k", "[L1/L2] 416k/320k", "[L1/L2] 448k/384k", - NULL }; menu = menu_bitrate; + menumax = sizeof(menu_bitrate) / sizeof(menu_bitrate[0]); break; } case V4L2_CID_IVTV_MONO:{ @@ -77,9 +77,9 @@ "JointStereo", "Dual", "Mono", - NULL }; menu = menu_mono; + menumax = sizeof(menu_mono) / sizeof(menu_mono[0]); break; } case V4L2_CID_IVTV_JOINT:{ @@ -88,9 +88,9 @@ "Subbands 8-31/bound=8", "Subbands 12-31/bound=12", "Subbands 16-31/bound=16", - NULL }; menu = menu_joint; + menumax = sizeof(menu_joint) / sizeof(menu_joint[0]); break; } case V4L2_CID_IVTV_EMPHASIS:{ @@ -98,50 +98,47 @@ "None", "50/15uS", "CCITT J.17", - NULL }; menu = menu_emph; + menumax = sizeof(menu_emph) / sizeof(menu_emph[0]); break; } case V4L2_CID_IVTV_CRC:{ const char *menu_crc[] = { "CRC off", "CRC on", - NULL }; menu = menu_crc; + menumax = sizeof(menu_crc) / sizeof(menu_crc[0]); break; } case V4L2_CID_IVTV_COPYRIGHT:{ const char *menu_copyright[] = { "Copyright off", "Copyright on", - NULL }; menu = menu_copyright; + menumax = sizeof(menu_copyright) / sizeof(menu_copyright[0]); break; } case V4L2_CID_IVTV_GEN:{ const char *menu_gen[] = { "Copy", "Original", - NULL }; menu = menu_gen; + menumax = sizeof(menu_gen) / sizeof(menu_gen[0]); break; } default: - IVTV_DEBUG_INFO("v4l2 ioctl: invalid control\n"); - return -EINVAL; - } - while (i && *menu) { - menu++; - } - if (*menu == NULL) { - IVTV_DEBUG_INFO("v4l2 ioctl: invalid menu index\n"); - return -EINVAL; - } - strncpy(qmenu->name, *menu, sizeof(qmenu->name)); + IVTV_DEBUG_INFO("v4l2 ioctl: invalid control (0x%08X)\n", qmenu->id); + return -EINVAL; + } + if (qmenu->index < 0 || qmenu->index >= menumax) { + IVTV_DEBUG_INFO( "v4l2 ioctl: invalid menu index (%d)\n", qmenu->index); + return -EINVAL; + } + strncpy(qmenu->name, menu[qmenu->index], sizeof(qmenu->name)); return 0; } @@ -262,7 +259,7 @@ ivtv_init_queryctrl(qctrl, V4L2_CTRL_TYPE_INTEGER, 0, 1, 0, 1); break; default: - IVTV_DEBUG_INFO("v4l2 ioctl: invalid control\n"); + IVTV_DEBUG_INFO("v4l2 ioctl: invalid control (0x%08X)\n", qctrl->id); return -EINVAL; } strncpy(qctrl->name, name, sizeof(qctrl->name) - 1); @@ -415,7 +412,7 @@ ivtv_audio_set_mute(itv, v); break; default: - IVTV_DEBUG_WARN("ctrl: invalid control\n"); + IVTV_DEBUG_WARN("ctrl: invalid control (0x%08X)\n", vctrl->id); return -EINVAL; } return 0; @@ -504,7 +501,7 @@ vctrl->value = ivtv_audio_get_mute(itv); break; default: - IVTV_DEBUG_WARN("ctrl: invalid control\n"); + IVTV_DEBUG_WARN("ctrl: invalid control (0x%08X)\n", vctrl->id); return -EINVAL; } return 0; diff -Naur ivtv-0.3.7k.orig/driver/v4l1-compat.c ivtv-0.3.7k/driver/v4l1-compat.c --- ivtv-0.3.7k.orig/driver/v4l1-compat.c 2005-08-16 13:31:30 +0200 +++ ivtv-0.3.7k/driver/v4l1-compat.c 2005-09-11 06:49:45 +0200 @@ -361,7 +361,12 @@ err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); if (err < 0) { dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); - break; + buffer->base = 0; + buffer->width = 0; + buffer->height = 0; + buffer->depth = 0; + buffer->bytesperline = 0; + return 0; } buffer->base = fbuf2.base; buffer->height = fbuf2.fmt.height;