1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/jpeglsdec: fix end check for xfrm

Fixes: out of array access
Fixes: 47871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-5646305956855808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6a82412bf3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2022-06-09 21:13:59 +02:00
parent d5d3f80e17
commit 36fdafb16d
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -465,19 +465,19 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
for (i = 0; i < s->height; i++) {
switch(s->xfrm) {
case 1:
for (x = off; x < w; x += 3) {
for (x = off; x + 2 < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += src[x+1] + 128;
}
break;
case 2:
for (x = off; x < w; x += 3) {
for (x = off; x + 2 < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
}
break;
case 3:
for (x = off; x < w; x += 3) {
for (x = off; x + 2 < w; x += 3) {
int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
src[x+0] = src[x+2] + g + 128;
src[x+2] = src[x+1] + g + 128;
@ -485,7 +485,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
}
break;
case 4:
for (x = off; x < w; x += 3) {
for (x = off; x + 2 < w; x += 3) {
int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);