zmbvdec: Check the buffer size for uncompressed data
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 11 Nov 2012 17:08:39 +0000 (18:08 +0100)
committerMartin Storsjö <martin@martin.st>
Thu, 12 Sep 2013 07:53:39 +0000 (10:53 +0300)
Also don't pointlessly set the buffer size to 1 after copying
one packet.

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

index 0b38926..65fa5ff 100644 (file)
@@ -499,8 +499,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
     }
 
     if (c->comp == 0) { //Uncompressed data
+        if (c->decomp_size < len) {
+            av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
+            return AVERROR_INVALIDDATA;
+        }
         memcpy(c->decomp_buf, buf, len);
-        c->decomp_size = 1;
     } else { // ZLIB-compressed data
         c->zstream.total_in = c->zstream.total_out = 0;
         c->zstream.next_in = buf;