diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-06-21 00:47:15 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-12-02 19:41:48 +0100 |
commit | a6d53b3028b4e799e55496e60349ad28021c61ac (patch) | |
tree | 0b46be265b6e9cf74f847c29402bd26c5ed287bb | |
parent | cabdd900b7bff44af335733cffdd7e32c793d6e2 (diff) | |
download | ffmpeg-a6d53b3028b4e799e55496e60349ad28021c61ac.tar.gz |
avcodec/alsdec: Check opt_order / sb_length in ra_block handling
Fixes: out of array access
Fixes: 15277/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5184853437317120
Fixes: 15280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5741062137577472
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0794494c8f2f756e3c9384dba21c54f7d4ba9286)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/alsdec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 6581a63ce6..9369ec10f6 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -784,14 +784,20 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) // read first value and residuals in case of a random access block if (bd->ra_block) { + start = FFMIN(opt_order, 3); + av_assert0(sb_length <= sconf->frame_length); + if (sb_length <= start) { + // opt_order or sb_length may be corrupted, either way this is unsupported and not well defined in the specification + av_log(avctx, AV_LOG_ERROR, "Sub block length smaller or equal start\n"); + return AVERROR_PATCHWELCOME; + } + if (opt_order) bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4); if (opt_order > 1) bd->raw_samples[1] = decode_rice(gb, FFMIN(s[0] + 3, ctx->s_max)); if (opt_order > 2) bd->raw_samples[2] = decode_rice(gb, FFMIN(s[0] + 1, ctx->s_max)); - - start = FFMIN(opt_order, 3); } // read all residuals |