[libav-stable] bmv: check for len being valid in bmv_decode_frame().

Anton Khirnov git at libav.org
Thu Apr 4 07:58:20 CEST 2013


Module: libav
Branch: master
Commit: b88f902125ee808c8366e9dcb3f21e4c227483fc

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Thu Mar 28 10:09:36 2013 +0100

bmv: check for len being valid in bmv_decode_frame().

It can be 0 or -1 for invalid files, which may result in invalid memory
access.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org

---

 libavcodec/bmv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c
index b6b685b..941051b 100644
--- a/libavcodec/bmv.c
+++ b/libavcodec/bmv.c
@@ -135,7 +135,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
         mode += 1 + advance_mode;
         if (mode >= 4)
             mode -= 3;
-        if (FFABS(dst_end - dst) < len)
+        if (len <= 0 || FFABS(dst_end - dst) < len)
             return AVERROR_INVALIDDATA;
         switch (mode) {
         case 1:



More information about the libav-stable mailing list