avformat/mov: Fix DoS in read_tfra()
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 4 Sep 2017 22:16:29 +0000 (00:16 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 8 Sep 2017 16:37:21 +0000 (18:37 +0200)
Fixes: Missing EOF check in loop
No testcase

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9cb4eb772839c5e1de2855d126bf74ff16d13382)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index cff3c70..6768aa2 100644 (file)
@@ -4702,6 +4702,13 @@ static int read_tfra(MOVContext *mov, AVIOContext *f)
     }
     for (i = 0; i < index->item_count; i++) {
         int64_t time, offset;
+
+        if (avio_feof(f)) {
+            index->item_count = 0;
+            av_freep(&index->items);
+            return AVERROR_INVALIDDATA;
+        }
+
         if (version == 1) {
             time   = avio_rb64(f);
             offset = avio_rb64(f);