avformat/vividas: Check av_xiphlacing() return value before use
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 21 Aug 2019 21:05:21 +0000 (23:05 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 22 Aug 2019 16:35:44 +0000 (18:35 +0200)
Fixes: out of array access
Fixes: 16277/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5696629440512000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/vividas.c

index 0c33ca2da8692ff873e21c16203d4baa465d51d7..645e322b6e7be938ec1507cff090ca18c0202c49 100644 (file)
@@ -392,8 +392,14 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
             p = st->codecpar->extradata;
             p[0] = 2;
 
-            for (j = 0; j < num_data - 1; j++)
-                offset += av_xiphlacing(&p[offset], data_len[j]);
+            for (j = 0; j < num_data - 1; j++) {
+                unsigned delta = av_xiphlacing(&p[offset], data_len[j]);
+                if (delta > data_len[j]) {
+                    av_free(pb);
+                    return AVERROR_INVALIDDATA;
+                }
+                offset += delta;
+            }
 
             for (j = 0; j < num_data; j++) {
                 int ret = avio_read(pb, &p[offset], data_len[j]);