Commit 5a21c7a0 authored by Hans Verkuil's avatar Hans Verkuil Committed by Greg Kroah-Hartman

media: vicodec: fix out-of-range values when decoding

[ Upstream commit be5a1509 ]

While decoding you need to make sure you do not get values < 0
or > 255. Note that since this code will also be used in userspace
utilities the clamp macro isn't used since that is kernel-only.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 17743861
...@@ -588,8 +588,14 @@ static void fill_decoder_block(u8 *dst, const s16 *input, int stride) ...@@ -588,8 +588,14 @@ static void fill_decoder_block(u8 *dst, const s16 *input, int stride)
int i, j; int i, j;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++, input++, dst++) {
*dst++ = *input++; if (*input < 0)
*dst = 0;
else if (*input > 255)
*dst = 255;
else
*dst = *input;
}
dst += stride - 8; dst += stride - 8;
} }
} }
......
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