[FFmpeg-devel,3/5] avcodec/smacker: Fix integer overflows in pred[] in smka_decode_frame()

Submitted by Michael Niedermayer on Sept. 30, 2019, 11:12 p.m.

Details

Message ID 20190930231254.23993-3-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Sept. 30, 2019, 11:12 p.m.
Fixes: signed integer overflow: -2147481503 + -32732 cannot be represented in type 'int'
Fixes: 17782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5769672225456128

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

Comments

Michael Niedermayer Oct. 20, 2019, 5:23 p.m.
On Tue, Oct 01, 2019 at 01:12:52AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147481503 + -32732 cannot be represented in type 'int'
> Fixes: 17782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5769672225456128
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/smacker.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index a2950c455b..3dd0e929d8 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -742,7 +742,7 @@  static int smka_decode_frame(AVCodecContext *avctx, void *data,
                     return AVERROR_INVALIDDATA;
                 }
                 val |= h[3].values[res] << 8;
-                pred[1] += sign_extend(val, 16);
+                pred[1] += (unsigned)sign_extend(val, 16);
                 *samples++ = pred[1];
             } else {
                 if(vlc[0].table)
@@ -763,7 +763,7 @@  static int smka_decode_frame(AVCodecContext *avctx, void *data,
                     return AVERROR_INVALIDDATA;
                 }
                 val |= h[1].values[res] << 8;
-                pred[0] += sign_extend(val, 16);
+                pred[0] += (unsigned)sign_extend(val, 16);
                 *samples++ = pred[0];
             }
         }