diff mbox series

[FFmpeg-devel,2/7] avcodec/vp9dsp_template: Fix some overflows in iadst8_1d()

Message ID 20201019142501.6867-2-michael@niedermayer.cc
State Accepted
Commit bca0735be52e471b1906aed34c60028d90646d90
Headers show
Series [FFmpeg-devel,1/7] avcodec/fits: Check bscale | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 19, 2020, 2:24 p.m. UTC
Fixes: signed integer overflow: 190587 * 11585 cannot be represented in type 'int'
Fixes: 26407/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-5086348408782848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/vp9dsp_template.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Oct. 24, 2020, 5:08 p.m. UTC | #1
On Mon, Oct 19, 2020 at 04:24:56PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 190587 * 11585 cannot be represented in type 'int'
> Fixes: 26407/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-5086348408782848
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vp9dsp_template.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/vp9dsp_template.c b/libavcodec/vp9dsp_template.c
index bfabe63536..3acf94c583 100644
--- a/libavcodec/vp9dsp_template.c
+++ b/libavcodec/vp9dsp_template.c
@@ -1275,10 +1275,10 @@  static av_always_inline void iadst8_1d(const dctcoef *in, ptrdiff_t stride,
     t6     =   (dctint)((1U << 13) + t4a - t6a) >> 14;
     t7     =   (dctint)((1U << 13) + t5a - t7a) >> 14;
 
-    out[3] = -(((t2 + t3) * 11585 + (1 << 13)) >> 14);
-    out[4] =   ((t2 - t3) * 11585 + (1 << 13)) >> 14;
-    out[2] =   ((t6 + t7) * 11585 + (1 << 13)) >> 14;
-    out[5] = -(((t6 - t7) * 11585 + (1 << 13)) >> 14);
+    out[3] = -((dctint)((t2 + t3) * 11585U + (1 << 13)) >> 14);
+    out[4] =   (dctint)((t2 - t3) * 11585U + (1 << 13)) >> 14;
+    out[2] =   (dctint)((t6 + t7) * 11585U + (1 << 13)) >> 14;
+    out[5] = -((dctint)((t6 - t7) * 11585U + (1 << 13)) >> 14);
 }
 
 itxfm_wrap(8, 5)