[FFmpeg-devel,6/6] avcodec/alsdec: Check k from being outside what our implementation can handle

Submitted by Michael Niedermayer on Aug. 25, 2019, 6:41 p.m.

Details

Message ID 20190825184158.10244-6-michael@niedermayer.cc
State Accepted
Commit e1255789941d213a8e193469d0687946c9fa4a63
Headers show

Commit Message

Michael Niedermayer Aug. 25, 2019, 6:41 p.m.
The specification does not seem to list what the maximum valid
value is

Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 16268/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5638164544225280

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

Comments

Michael Niedermayer Sept. 11, 2019, 8:48 p.m.
On Sun, Aug 25, 2019 at 08:41:58PM +0200, Michael Niedermayer wrote:
> The specification does not seem to list what the maximum valid
> value is
> 
> Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
> Fixes: 16268/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5638164544225280
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/alsdec.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 11bbd38f58..00fbb9e2cc 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -831,6 +831,9 @@  static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
             k    [sb] = s[sb] > b ? s[sb] - b : 0;
             delta[sb] = 5 - s[sb] + k[sb];
 
+            if (k[sb] >= 32)
+                return AVERROR_INVALIDDATA;
+
             ff_bgmc_decode(gb, sb_len, current_res,
                         delta[sb], sx[sb], &high, &low, &value, ctx->bgmc_lut, ctx->bgmc_lut_status);