]> git.sesse.net Git - ffmpeg/commitdiff
rv10: improve buffer size check.
authorAnton Khirnov <anton@khirnov.net>
Sun, 3 Feb 2013 07:42:02 +0000 (08:42 +0100)
committerAnton Khirnov <anton@khirnov.net>
Wed, 6 Feb 2013 20:47:57 +0000 (21:47 +0100)
Check slice count and input buffer size before constructing a possibly
invalid pointer, not after.

libavcodec/rv10.c

index 8cce6cf6994ab4c9b85e1b1bd65eef0b70b2c3ec..38abf7841a8af7582c088b56c35ff0d872fb4376 100644 (file)
@@ -659,11 +659,15 @@ static int rv10_decode_frame(AVCodecContext *avctx,
     if(!avctx->slice_count){
         slice_count = (*buf++) + 1;
         buf_size--;
+
+        if (!slice_count || buf_size <= 8 * slice_count) {
+            av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", slice_count);
+            return AVERROR_INVALIDDATA;
+        }
+
         slices_hdr = buf + 4;
         buf += 8 * slice_count;
         buf_size -= 8 * slice_count;
-        if (buf_size <= 0)
-            return AVERROR_INVALIDDATA;
     }else
         slice_count = avctx->slice_count;