Commit 1c97035e authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/error_resilience: Fix integer overflow in filter181()

Fixes: runtime error: signed integer overflow: 197710 * 10923 cannot be represented in type 'int'
Fixes: 7010/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5667127596941312

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent de841fbe
...@@ -107,7 +107,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride) ...@@ -107,7 +107,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride)
dc = -prev_dc + dc = -prev_dc +
data[x + y * stride] * 8 - data[x + y * stride] * 8 -
data[x + 1 + y * stride]; data[x + 1 + y * stride];
dc = (dc * 10923 + 32768) >> 16; dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
prev_dc = data[x + y * stride]; prev_dc = data[x + y * stride];
data[x + y * stride] = dc; data[x + y * stride] = dc;
} }
...@@ -123,7 +123,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride) ...@@ -123,7 +123,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride)
dc = -prev_dc + dc = -prev_dc +
data[x + y * stride] * 8 - data[x + y * stride] * 8 -
data[x + (y + 1) * stride]; data[x + (y + 1) * stride];
dc = (dc * 10923 + 32768) >> 16; dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
prev_dc = data[x + y * stride]; prev_dc = data[x + y * stride];
data[x + y * stride] = dc; data[x + y * stride] = dc;
} }
......
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