diff mbox

[FFmpeg-devel] avcodec/diracdec: Check component quant

Message ID 20181114093708.8377-1-michael@niedermayer.cc
State Accepted
Commit 28c96c2ce2781c2cd147a9f3c299e18ce1dc7ff8
Headers show

Commit Message

Michael Niedermayer Nov. 14, 2018, 9:37 a.m. UTC
Fixes: Timeout
Fixes: 10708/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5730140957442048

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

Comments

Michael Niedermayer Nov. 27, 2018, 11 a.m. UTC | #1
On Wed, Nov 14, 2018 at 10:37:08AM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 10708/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5730140957442048
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/diracdec.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index af561d1426..fd23139062 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -676,6 +676,11 @@  static int decode_component(DiracContext *s, int comp)
             b->length = get_interleaved_ue_golomb(&s->gb);
             if (b->length) {
                 b->quant = get_interleaved_ue_golomb(&s->gb);
+                if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
+                    av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
+                    b->quant = 0;
+                    return AVERROR_INVALIDDATA;
+                }
                 align_get_bits(&s->gb);
                 b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
                 b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0));