]> git.sesse.net Git - ffmpeg/commitdiff
mov: Rework the check for invalid indexes in stsc
authorVittorio Giovara <vittorio.giovara@gmail.com>
Wed, 13 Jul 2016 19:02:41 +0000 (15:02 -0400)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Wed, 20 Jul 2016 17:30:22 +0000 (19:30 +0200)
There are samples with invalid stsc that may work fine as is and
do not need extradata change. So ignore any out of range index, and
error out only when explode is set.

Found-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
libavformat/mov.c

index 826be02abcb90056f0c6ac9e9fe14ed4a5af711a..ff39b58ef1c9adde79403a2e1d9807b91c436f3e 100644 (file)
@@ -1949,8 +1949,13 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         sc->stsc_data[i].first = avio_rb32(pb);
         sc->stsc_data[i].count = avio_rb32(pb);
         sc->stsc_data[i].id = avio_rb32(pb);
-        if (sc->stsc_data[i].id > sc->stsd_count)
-            return AVERROR_INVALIDDATA;
+        if (sc->stsc_data[i].id < 0 || sc->stsc_data[i].id > sc->stsd_count) {
+            sc->stsc_data[i].id = 0;
+            if (c->fc->error_recognition & AV_EF_EXPLODE) {
+                av_log(c->fc, AV_LOG_ERROR, "Invalid stsc index.\n");
+                return AVERROR_INVALIDDATA;
+            }
+        }
     }
 
     sc->stsc_count = i;