avcodec/alsdec: Check for overread
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 4 Jun 2015 20:59:34 +0000 (22:59 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 28 Jul 2015 00:33:56 +0000 (02:33 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit c2657633187e325a439e3297fd9ccd0522ab2e39)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/alsdec.c

index a55354b..708c714 100644 (file)
@@ -1493,6 +1493,11 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
 
     // TODO: read_diff_float_data
 
+    if (get_bits_left(gb) < 0) {
+        av_log(ctx->avctx, AV_LOG_ERROR, "Overread %d\n", -get_bits_left(gb));
+        return AVERROR_INVALIDDATA;
+    }
+
     return 0;
 }