The patch number 8920 was added via Hans Verkuil <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Hans Verkuil  <[EMAIL PROTECTED]>
cx18/ivtv: fix check of window boundaries for VIDIOC_S_FMT


It was possible to set out-of-bounds windows sizes, this is now
fixed.

Priority: normal

Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>


---

 linux/drivers/media/video/cx18/cx18-ioctl.c |    6 +--
 linux/drivers/media/video/ivtv/ivtv-ioctl.c |   33 +++++++-------------
 2 files changed, 16 insertions(+), 23 deletions(-)

diff -r f3800add7a9c -r 68ffb491432a linux/drivers/media/video/cx18/cx18-ioctl.c
--- a/linux/drivers/media/video/cx18/cx18-ioctl.c       Sat Sep 06 12:22:13 
2008 +0200
+++ b/linux/drivers/media/video/cx18/cx18-ioctl.c       Sat Sep 06 13:24:37 
2008 +0200
@@ -201,7 +201,6 @@ static int cx18_try_fmt_vid_cap(struct f
 {
        struct cx18_open_id *id = fh;
        struct cx18 *cx = id->cx;
-
        int w = fmt->fmt.pix.width;
        int h = fmt->fmt.pix.height;
 
@@ -249,8 +248,7 @@ static int cx18_s_fmt_vid_cap(struct fil
        struct cx18_open_id *id = fh;
        struct cx18 *cx = id->cx;
        int ret;
-       int w = fmt->fmt.pix.width;
-       int h = fmt->fmt.pix.height;
+       int w, h;
 
        ret = v4l2_prio_check(&cx->prio, &id->prio);
        if (ret)
@@ -259,6 +257,8 @@ static int cx18_s_fmt_vid_cap(struct fil
        ret = cx18_try_fmt_vid_cap(file, fh, fmt);
        if (ret)
                return ret;
+       w = fmt->fmt.pix.width;
+       h = fmt->fmt.pix.height;
 
        if (cx->params.width == w && cx->params.height == h)
                return 0;
diff -r f3800add7a9c -r 68ffb491432a linux/drivers/media/video/ivtv/ivtv-ioctl.c
--- a/linux/drivers/media/video/ivtv/ivtv-ioctl.c       Sat Sep 06 12:22:13 
2008 +0200
+++ b/linux/drivers/media/video/ivtv/ivtv-ioctl.c       Sat Sep 06 13:24:37 
2008 +0200
@@ -512,27 +512,20 @@ static int ivtv_try_fmt_vid_out(struct f
 static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct 
v4l2_format *fmt)
 {
        struct ivtv_open_id *id = fh;
-       s32 w, h;
-       int field;
-       int ret;
-
-       w = fmt->fmt.pix.width;
-       h = fmt->fmt.pix.height;
-       field = fmt->fmt.pix.field;
-       ret = ivtv_g_fmt_vid_out(file, fh, fmt);
+       s32 w = fmt->fmt.pix.width;
+       s32 h = fmt->fmt.pix.height;
+       int field = fmt->fmt.pix.field;
+       int ret = ivtv_g_fmt_vid_out(file, fh, fmt);
+
+       if (!ret && id->type == IVTV_DEC_STREAM_TYPE_YUV) {
+               fmt->fmt.pix.field = field;
+               w = min(w, 720);
+               w = max(w, 2);
+               h = min(h, 576);
+               h = max(h, 2);
+       }
        fmt->fmt.pix.width = w;
        fmt->fmt.pix.height = h;
-       if (!ret && id->type == IVTV_DEC_STREAM_TYPE_YUV) {
-               fmt->fmt.pix.field = field;
-               if (fmt->fmt.pix.width < 2)
-                       fmt->fmt.pix.width = 2;
-               if (fmt->fmt.pix.width > 720)
-                       fmt->fmt.pix.width = 720;
-               if (fmt->fmt.pix.height < 2)
-                       fmt->fmt.pix.height = 2;
-               if (fmt->fmt.pix.height > 576)
-                       fmt->fmt.pix.height = 576;
-       }
        return ret;
 }
 
@@ -560,9 +553,9 @@ static int ivtv_s_fmt_vid_cap(struct fil
        struct ivtv_open_id *id = fh;
        struct ivtv *itv = id->itv;
        struct cx2341x_mpeg_params *p = &itv->params;
+       int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
        int w = fmt->fmt.pix.width;
        int h = fmt->fmt.pix.height;
-       int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
 
        if (ret)
                return ret;


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/68ffb491432a10fa853b03f6f748bb43a304c5ab

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to