Browse code

wmaprodec: tighter check for num_vec_coeffs

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2012/04/22 10:47:53
Showing 1 changed files
... ...
@@ -1166,6 +1166,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1166 1166
             transmit_coeffs = 1;
1167 1167
     }
1168 1168
 
1169
+    av_assert0(s->subframe_len <= WMAPRO_BLOCK_MAX_SIZE);
1169 1170
     if (transmit_coeffs) {
1170 1171
         int step;
1171 1172
         int quant_step = 90 * s->bits_per_sample >> 4;
... ...
@@ -1176,7 +1177,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1176 1176
             for (i = 0; i < s->channels_for_cur_subframe; i++) {
1177 1177
                 int c = s->channel_indexes_for_cur_subframe[i];
1178 1178
                 int num_vec_coeffs = get_bits(&s->gb, num_bits) << 2;
1179
-                if (num_vec_coeffs > WMAPRO_BLOCK_MAX_SIZE) {
1179
+                if (num_vec_coeffs > s->subframe_len) {
1180 1180
                     av_log(s->avctx, AV_LOG_ERROR, "num_vec_coeffs %d is too large\n", num_vec_coeffs);
1181 1181
                     return AVERROR_INVALIDDATA;
1182 1182
                 }