diff mbox

[FFmpeg-devel,5/5] avcodec/truespeech: Fix an integer overflow in truespeech_synth()

Message ID 20191114163408.16682-5-michael@niedermayer.cc
State Accepted
Commit 8bcb5fbab5e30c3001c27a8309c94eb1f66b969f
Headers show

Commit Message

Michael Niedermayer Nov. 14, 2019, 4:34 p.m. UTC
Fixes: signed integer overflow: 2147483188 + 2048 cannot be represented in type 'int'
Fixes: 18741/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUESPEECH_fuzzer-5748950460268544

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

Comments

Michael Niedermayer Dec. 9, 2019, 10:28 p.m. UTC | #1
On Thu, Nov 14, 2019 at 05:34:08PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147483188 + 2048 cannot be represented in type 'int'
> Fixes: 18741/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUESPEECH_fuzzer-5748950460268544
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/truespeech.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index d7c2d535e2..3cdae8c556 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -255,7 +255,7 @@  static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
         int sum = 0;
         for(k = 0; k < 8; k++)
             sum += ptr0[k] * (unsigned)ptr1[k];
-        sum = out[i] + ((sum + 0x800) >> 12);
+        sum = out[i] + ((int)(sum + 0x800U) >> 12);
         out[i] = av_clip(sum, -0x7FFE, 0x7FFE);
         for(k = 7; k > 0; k--)
             ptr0[k] = ptr0[k - 1];