[FFmpeg-cvslog] bmv: fix integer overflows in vlc decoder.
Michael Niedermayer
git at videolan.org
Thu Jun 7 01:44:20 CEST 2012
ffmpeg | branch: release/0.11 | Michael Niedermayer <michaelni at gmx.at> | Sat Jun 2 04:04:29 2012 +0200| [ae5f69a98fbdd6cba967ec117b3617e1a348fa42] | committer: Michael Niedermayer
bmv: fix integer overflows in vlc decoder.
Fixes part of Ticket1373
Found-by: Piotr Bandurski <ami_stuff at o2.pl>
Based-on-patch-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 679c578cb8e82df6fdee977e3137a26a680ad346)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae5f69a98fbdd6cba967ec117b3617e1a348fa42
---
libavcodec/bmv.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c
index 37c8448..9740b11 100644
--- a/libavcodec/bmv.c
+++ b/libavcodec/bmv.c
@@ -21,6 +21,7 @@
#include "avcodec.h"
#include "bytestream.h"
+#include "libavutil/avassert.h"
enum BMVFlags{
BMV_NOP = 0,
@@ -52,7 +53,7 @@ typedef struct BMVDecContext {
static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int frame_off)
{
- int val, saved_val = 0;
+ unsigned val, saved_val = 0;
int tmplen = src_len;
const uint8_t *src, *source_end = source + src_len;
uint8_t *frame_end = frame + SCREEN_WIDE * SCREEN_HIGH;
@@ -98,6 +99,8 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
}
if (!(val & 0xC)) {
for (;;) {
+ if(shift>22)
+ return -1;
if (!read_two_nibbles) {
if (src < source || src >= source_end)
return -1;
@@ -131,6 +134,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
}
advance_mode = val & 1;
len = (val >> 1) - 1;
+ av_assert0(len>0);
mode += 1 + advance_mode;
if (mode >= 4)
mode -= 3;
More information about the ffmpeg-cvslog
mailing list