[FFmpeg-cvslog] mov: Rework the check for invalid indexes in stsc

Vittorio Giovara git at videolan.org
Thu Feb 2 12:17:03 EET 2017


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Jul 13 15:02:41 2016 -0400| [ed9b2a5178d7a7c5a95694da3a808af327f36aff] | committer: Vittorio Giovara

mov: Rework the check for invalid indexes in stsc

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 at stupeflix.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed9b2a5178d7a7c5a95694da3a808af327f36aff
---

 libavformat/mov.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 826be02..ff39b58 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -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;



More information about the ffmpeg-cvslog mailing list