[04/10] zmbvdec: Check the buffer size for uncompressed data

Message ID 1378932481-98398-4-git-send-email-martin@martin.st
State Committed
Commit 0d61f260010707f3028b818e8b24598e1a83d696
Headers show

Commit Message

Martin Storsjö Sept. 11, 2013, 8:47 p.m.
From: Michael Niedermayer <michaelni@gmx.at>

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
---
 libavcodec/zmbv.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Luca Barbato Sept. 11, 2013, 9:03 p.m. | #1
On 11/09/13 22:47, Martin Storsjö wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
> 
> 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
> ---
>  libavcodec/zmbv.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 

Ok.

Patch

diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 0b38926..65fa5ff 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -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;