avcodec/mjpegdec: Clip DC also on the negative side.
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 12 Jul 2017 14:24:18 +0000 (16:24 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 12 Jul 2017 14:32:27 +0000 (16:32 +0200)
Fixes: runtime error: signed integer overflow: -16711425 + -2130772346 cannot be represented in type 'int'
Fixes: 2533/clusterfuzz-testcase-minimized-5372857678823424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mjpegdec.c

index e4e99e0..387cead 100644 (file)
@@ -716,7 +716,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
         return AVERROR_INVALIDDATA;
     }
     val = val * quant_matrix[0] + s->last_dc[component];
-    val = FFMIN(val, 32767);
+    val = av_clip_int16(val);
     s->last_dc[component] = val;
     block[0] = val;
     /* AC coefs */