Commit 506bbbc0 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mjpegdec: Clip DC also on the negative side.

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/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c28f648b)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 910878e4
...@@ -693,7 +693,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component, ...@@ -693,7 +693,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
val = val * quant_matrix[0] + s->last_dc[component]; val = val * quant_matrix[0] + s->last_dc[component];
val = FFMIN(val, 32767); val = av_clip_int16(val);
s->last_dc[component] = val; s->last_dc[component] = val;
block[0] = val; block[0] = val;
/* AC coefs */ /* AC coefs */
......
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