diff mbox

[FFmpeg-devel,1/2] avcodec/agm: Check output size before allocation

Message ID 20190424203510.14956-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer April 24, 2019, 8:35 p.m. UTC
Fixes: OOM
Fixes: 14198/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5723579234123776

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

Comments

Michael Niedermayer April 30, 2019, 7:06 p.m. UTC | #1
On Wed, Apr 24, 2019 at 10:35:09PM +0200, Michael Niedermayer wrote:
> Fixes: OOM
> Fixes: 14198/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5723579234123776
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/agm.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index 332e33897c..f7cf8513d0 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -1049,6 +1049,9 @@  static int decode_huffman2(AVCodecContext *avctx, int header, int size)
 
     s->output_size = get_bits_long(gb, 32);
 
+    if (s->output_size > avctx->width * avctx->height * 9L + 10000)
+        return AVERROR_INVALIDDATA;
+
     av_fast_padded_malloc(&s->output, &s->padded_output_size, s->output_size);
     if (!s->output)
         return AVERROR(ENOMEM);