mpc8: Check the seek table size parsed from the bitstream
authorMartin Storsjö <martin@martin.st>
Wed, 11 Sep 2013 19:47:06 +0000 (22:47 +0300)
committerMartin Storsjö <martin@martin.st>
Thu, 12 Sep 2013 07:54:05 +0000 (10:54 +0300)
Limit the size to INT_MAX/2 (for simplicity) to be sure that
size + FF_INPUT_BUFFER_PADDING_SIZE won't overflow.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/mpc8.c

index c3c70e0..29001b1 100644 (file)
@@ -145,6 +145,10 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
         av_log(s, AV_LOG_ERROR, "No seek table at given position\n");
         return;
     }
+    if (size < 0 || size >= INT_MAX / 2) {
+        av_log(s, AV_LOG_ERROR, "Bad seek table size\n");
+        return;
+    }
     if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
         return;
     avio_read(s->pb, buf, size);