riff: check for eof if chunk size and code are 0
authorLuca Barbato <lu_zero@gentoo.org>
Sat, 20 Apr 2013 11:36:44 +0000 (13:36 +0200)
committerDiego Biurrun <diego@biurrun.de>
Sun, 21 Apr 2013 16:20:30 +0000 (18:20 +0200)
Prevent an infinite loop.

Inspired by a patch from Michael Niedermayer

CC: libav-stable@libav.org
Signed-off-by: Diego Biurrun <diego@biurrun.de>
libavformat/riff.c

index 694d299..2191c33 100644 (file)
@@ -785,6 +785,10 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size)
         if (!chunk_code) {
             if (chunk_size)
                 avio_skip(pb, chunk_size);
+            else if (pb->eof_reached) {
+                av_log(s, AV_LOG_WARNING, "truncated file\n");
+                return AVERROR_EOF;
+            }
             continue;
         }