avcodec/alsdec: Check r to prevent out of array read
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 7 Jun 2016 18:50:38 +0000 (20:50 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 7 Jun 2016 19:10:22 +0000 (21:10 +0200)
No testcase known

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/alsdec.c

index 842fc7d..a7e58a2 100644 (file)
@@ -767,6 +767,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
 
             r                 = get_unary(gb, 0, 4);
             c                 = get_bits(gb, 2);
+            if (r >= 4) {
+                av_log(avctx, AV_LOG_ERROR, "r overflow\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             bd->ltp_gain[2]   = ltp_gain_values[r][c];
 
             bd->ltp_gain[3]   = decode_rice(gb, 2) << 3;