]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/hcom: Check the root entry and the right entries
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 7 Oct 2019 14:56:11 +0000 (16:56 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 24 Oct 2019 22:22:33 +0000 (00:22 +0200)
Fixes: Segfault
Fixes: 17991/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCOM_fuzzer-5647235349479424
Also fixes related memleak

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/hcom.c

index 0559b050c32a86dcfc679ad837b57bf55cca2b89..8300676f98a6519af81954e9fd2097a89dcadef5 100644 (file)
@@ -66,8 +66,15 @@ static av_cold int hcom_init(AVCodecContext *avctx)
         s->dict[i].r = AV_RB16(avctx->extradata + 6 + 4 * i + 2);
         if (s->dict[i].l >= 0 &&
             (s->dict[i].l >= s->dict_entries ||
-             s->dict[i].r >= s->dict_entries))
+             s->dict[i].r >= s->dict_entries ||
+             s->dict[i].r < 0 )) {
+            av_freep(&s->dict);
             return AVERROR_INVALIDDATA;
+        }
+    }
+    if (s->dict[0].l < 0) {
+        av_freep(&s->dict);
+        return AVERROR_INVALIDDATA;
     }
 
     avctx->sample_fmt = AV_SAMPLE_FMT_U8;