[FFmpeg-cvslog] mdec: check for out of bounds read
Federico Tomassetti
git at videolan.org
Mon Feb 23 21:29:21 CET 2015
ffmpeg | branch: master | Federico Tomassetti <ftomassetti at groupon.com> | Wed Feb 18 12:11:43 2015 +0000| [161442ff2c4b0dd8a5072c6bbe6bf55303fffccf] | committer: Luca Barbato
mdec: check for out of bounds read
Bug-Id: CID 1257501
CC: libav-stable at libav.org
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=161442ff2c4b0dd8a5072c6bbe6bf55303fffccf
---
libavcodec/mdec.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 6b70e37..2a779c1 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -86,7 +86,12 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
if (level == 127) {
break;
} else if (level != 0) {
- i += run;
+ i += run;
+ if (i > 63) {
+ av_log(a->avctx, AV_LOG_ERROR,
+ "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
+ return AVERROR_INVALIDDATA;
+ }
j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 3;
level = (level ^ SHOW_SBITS(re, &a->gb, 1)) - SHOW_SBITS(re, &a->gb, 1);
@@ -96,8 +101,13 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
run = SHOW_UBITS(re, &a->gb, 6)+1; LAST_SKIP_BITS(re, &a->gb, 6);
UPDATE_CACHE(re, &a->gb);
level = SHOW_SBITS(re, &a->gb, 10); SKIP_BITS(re, &a->gb, 10);
- i += run;
- j = scantable[i];
+ i += run;
+ if (i > 63) {
+ av_log(a->avctx, AV_LOG_ERROR,
+ "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
+ return AVERROR_INVALIDDATA;
+ }
+ j = scantable[i];
if (level < 0) {
level = -level;
level = (level * qscale * quant_matrix[j]) >> 3;
@@ -108,10 +118,6 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
level = (level - 1) | 1;
}
}
- if (i > 63) {
- av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
- return AVERROR_INVALIDDATA;
- }
block[j] = level;
}
More information about the ffmpeg-cvslog
mailing list