[FFmpeg-devel,4/4] avcodec/apedec: Fix integer overflow in filter_3800()

Submitted by Michael Niedermayer on Oct. 20, 2019, 11:20 p.m.

Details

Message ID 20191020232059.19471-4-michael@niedermayer.cc
State Accepted
Commit 1c038c5c63375883a8a94332cffd701c4cb1301a
Headers show

Commit Message

Michael Niedermayer Oct. 20, 2019, 11:20 p.m.
Fixes: signed integer overflow: 2117181180 + 60483298 cannot be represented in type 'int'
Fixes: 18344/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5685327791915008

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

Comments

Michael Niedermayer Nov. 9, 2019, 4:25 p.m.
On Mon, Oct 21, 2019 at 01:20:59AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2117181180 + 60483298 cannot be represented in type 'int'
> Fixes: 18344/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5685327791915008
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/apedec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 75c6a96437..72d72f9346 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -885,7 +885,7 @@  static av_always_inline int filter_3800(APEPredictor *p,
     p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign;
 
     p->filterB[filter] = p->lastA[filter] + (predictionB >> shift);
-    p->filterA[filter] = p->filterB[filter] + ((int)(p->filterA[filter] * 31U) >> 5);
+    p->filterA[filter] = p->filterB[filter] + (unsigned)((int)(p->filterA[filter] * 31U) >> 5);
 
     return p->filterA[filter];
 }