]> git.sesse.net Git - ffmpeg/commitdiff
avformat/ape: Error out in case of EOF in the header
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 24 Jul 2020 21:51:11 +0000 (23:51 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 26 Jul 2020 16:29:57 +0000 (18:29 +0200)
Fixes: OOM
Fixes: 24375/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216862443241472
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/ape.c

index 39a584aa981148c40da26cd8863276cec8330628..d92cb2867dd7a97f069f44313d330c78b2621a1f 100644 (file)
@@ -253,7 +253,7 @@ static int ape_read_header(AVFormatContext * s)
             avio_skip(pb, ape->wavheaderlength);
     }
 
-    if(!ape->totalframes){
+    if(!ape->totalframes || pb->eof_reached){
         av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
         return AVERROR(EINVAL);
     }
@@ -298,8 +298,11 @@ static int ape_read_header(AVFormatContext * s)
             for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
                 ape->bittable[i] = avio_r8(pb);
         }
-        if (pb->eof_reached)
-            av_log(s, AV_LOG_WARNING, "File truncated\n");
+        if (pb->eof_reached) {
+            av_log(s, AV_LOG_ERROR, "File truncated\n");
+            ret = AVERROR_INVALIDDATA;
+            goto fail;
+        }
     }
 
     ape->frames[0].pos     = ape->firstframe;