diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-09-06 07:24:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:59 -0400 |
commit | effc3466d32108bec7da19aa23c1fddee9cafbab (patch) | |
tree | bfae96d8ffbe9d249f120a56cbdeb2d54a0a526c /drivers/media/video/ivtv/ivtv-ioctl.c | |
parent | ff5f26b40ab43a6c263834665bfa10d6114a27cd (diff) |
V4L/DVB (8920): 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.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-ioctl.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-ioctl.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 61030309d0ad..e67bf1b15cf3 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -512,27 +512,20 @@ static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_ | |||
512 | static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) | 512 | static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) |
513 | { | 513 | { |
514 | struct ivtv_open_id *id = fh; | 514 | struct ivtv_open_id *id = fh; |
515 | s32 w, h; | 515 | s32 w = fmt->fmt.pix.width; |
516 | int field; | 516 | s32 h = fmt->fmt.pix.height; |
517 | int ret; | 517 | int field = fmt->fmt.pix.field; |
518 | int ret = ivtv_g_fmt_vid_out(file, fh, fmt); | ||
518 | 519 | ||
519 | w = fmt->fmt.pix.width; | ||
520 | h = fmt->fmt.pix.height; | ||
521 | field = fmt->fmt.pix.field; | ||
522 | ret = ivtv_g_fmt_vid_out(file, fh, fmt); | ||
523 | fmt->fmt.pix.width = w; | ||
524 | fmt->fmt.pix.height = h; | ||
525 | if (!ret && id->type == IVTV_DEC_STREAM_TYPE_YUV) { | 520 | if (!ret && id->type == IVTV_DEC_STREAM_TYPE_YUV) { |
526 | fmt->fmt.pix.field = field; | 521 | fmt->fmt.pix.field = field; |
527 | if (fmt->fmt.pix.width < 2) | 522 | w = min(w, 720); |
528 | fmt->fmt.pix.width = 2; | 523 | w = max(w, 2); |
529 | if (fmt->fmt.pix.width > 720) | 524 | h = min(h, 576); |
530 | fmt->fmt.pix.width = 720; | 525 | h = max(h, 2); |
531 | if (fmt->fmt.pix.height < 2) | ||
532 | fmt->fmt.pix.height = 2; | ||
533 | if (fmt->fmt.pix.height > 576) | ||
534 | fmt->fmt.pix.height = 576; | ||
535 | } | 526 | } |
527 | fmt->fmt.pix.width = w; | ||
528 | fmt->fmt.pix.height = h; | ||
536 | return ret; | 529 | return ret; |
537 | } | 530 | } |
538 | 531 | ||
@@ -560,9 +553,9 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f | |||
560 | struct ivtv_open_id *id = fh; | 553 | struct ivtv_open_id *id = fh; |
561 | struct ivtv *itv = id->itv; | 554 | struct ivtv *itv = id->itv; |
562 | struct cx2341x_mpeg_params *p = &itv->params; | 555 | struct cx2341x_mpeg_params *p = &itv->params; |
556 | int ret = ivtv_try_fmt_vid_cap(file, fh, fmt); | ||
563 | int w = fmt->fmt.pix.width; | 557 | int w = fmt->fmt.pix.width; |
564 | int h = fmt->fmt.pix.height; | 558 | int h = fmt->fmt.pix.height; |
565 | int ret = ivtv_try_fmt_vid_cap(file, fh, fmt); | ||
566 | 559 | ||
567 | if (ret) | 560 | if (ret) |
568 | return ret; | 561 | return ret; |