Commit 82bdb26a authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivid: sanitize selection rectangle

Handle values like ~0 as width, height, left or top fields.
Just strip off the top 16 bits will ensure that the calculations
remain OK.

Found with v4l2-compliance.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 29813a6f
...@@ -694,6 +694,9 @@ int vivid_vid_adjust_sel(unsigned flags, struct v4l2_rect *r) ...@@ -694,6 +694,9 @@ int vivid_vid_adjust_sel(unsigned flags, struct v4l2_rect *r)
unsigned w = r->width; unsigned w = r->width;
unsigned h = r->height; unsigned h = r->height;
/* sanitize w and h in case someone passes ~0 as the value */
w &= 0xffff;
h &= 0xffff;
if (!(flags & V4L2_SEL_FLAG_LE)) { if (!(flags & V4L2_SEL_FLAG_LE)) {
w++; w++;
h++; h++;
...@@ -718,8 +721,9 @@ int vivid_vid_adjust_sel(unsigned flags, struct v4l2_rect *r) ...@@ -718,8 +721,9 @@ int vivid_vid_adjust_sel(unsigned flags, struct v4l2_rect *r)
r->top = 0; r->top = 0;
if (r->left < 0) if (r->left < 0)
r->left = 0; r->left = 0;
r->left &= ~1; /* sanitize left and top in case someone passes ~0 as the value */
r->top &= ~1; r->left &= 0xfffe;
r->top &= 0xfffe;
if (r->left + w > MAX_WIDTH) if (r->left + w > MAX_WIDTH)
r->left = MAX_WIDTH - w; r->left = MAX_WIDTH - w;
if (r->top + h > MAX_HEIGHT) if (r->top + h > MAX_HEIGHT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment