aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-09 12:50:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-09 12:50:05 +0100
commitce167a49ba706809ada8f80f600b24c12a04e510 (patch)
tree5745da5f37ff3973e9655c9a4d2fa904a6ec3b79
parent4e6f1df657224d560691246cee4d596e8760fa9d (diff)
parentb2b359f12465c8445484be24278b324da8ebb0e1 (diff)
downloadffmpeg-ce167a49ba706809ada8f80f600b24c12a04e510.tar.gz
Merge commit 'b2b359f12465c8445484be24278b324da8ebb0e1' into release/2.2
* commit 'b2b359f12465c8445484be24278b324da8ebb0e1': mdec: check for out of bounds read Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mdec.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 1567e14a1f..157cbc3dd9 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -83,7 +83,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);
@@ -93,8 +98,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;
@@ -105,10 +115,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;
}