[FFmpeg-devel,1/4] avcodec/alac: fix undefined behavior with INT_MIN in lpc_prediction()

Submitted by Michael Niedermayer on Sept. 6, 2019, 10:47 a.m.

Details

Message ID 20190906104747.10286-1-michael@niedermayer.cc
State Accepted
Commit 0831cbfe099192098d91e049ed9cf03c5a9cb376
Headers show

Commit Message

Michael Niedermayer Sept. 6, 2019, 10:47 a.m.
Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
Fixes: 16786/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5632818851348480

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

Comments

Michael Niedermayer Sept. 24, 2019, 1:29 p.m.
On Fri, Sep 06, 2019 at 12:47:44PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
> Fixes: 16786/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5632818851348480
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/alac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply patchset

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 782d461b22..c606f2af0e 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -222,7 +222,7 @@  static void lpc_prediction(int32_t *error_buffer, uint32_t *buffer_out,
         /* adapt LPC coefficients */
         error_sign = sign_only(error_val);
         if (error_sign) {
-            for (j = 0; j < lpc_order && (int)error_val * error_sign > 0; j++) {
+            for (j = 0; j < lpc_order && (int)(error_val * error_sign) > 0; j++) {
                 int sign;
                 val  = d - pred[j];
                 sign = sign_only(val) * error_sign;