[FFmpeg-devel,3/3] avcodec/agm: Check that there is available input in read_code()

Submitted by Michael Niedermayer on April 6, 2019, 11:21 p.m.

Details

Message ID 20190406232114.12961-3-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer April 6, 2019, 11:21 p.m.
Fixes: Timeout (46sec -> 7ms)
Fixes: 14030/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5721258760601600

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 24, 2019, 10:39 a.m.
On Sun, Apr 07, 2019 at 01:21:14AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (46sec -> 7ms)
> Fixes: 14030/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5721258760601600
> 
> 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

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index cbd45e8095..965be123f4 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -88,6 +88,9 @@  static int read_code(GetBitContext *gb, int *oskip, int *level, int *map, int mo
 {
     int len = 0, skip = 0, max;
 
+    if (get_bits_left(gb) < 2)
+        return AVERROR_INVALIDDATA;
+
     if (show_bits(gb, 2)) {
         switch (show_bits(gb, 4)) {
         case 1: