shorten: Prevent block size from increasing
authorLaurent Aimar <fenrir@elivagar.org>
Sun, 2 Oct 2011 00:48:12 +0000 (00:48 +0000)
committerJanne Grunau <janne-libav@jannau.net>
Fri, 7 Oct 2011 14:25:30 +0000 (16:25 +0200)
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
libavcodec/shorten.c

index 80b1b4d..8f7436e 100644 (file)
@@ -482,9 +482,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
             case FN_BITSHIFT:
                 s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
                 break;
-            case FN_BLOCKSIZE:
-                s->blocksize = get_uint(s, av_log2(s->blocksize));
+            case FN_BLOCKSIZE: {
+                int blocksize = get_uint(s, av_log2(s->blocksize));
+                if (blocksize > s->blocksize) {
+                    av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n");
+                    return AVERROR_PATCHWELCOME;
+                }
+                s->blocksize = blocksize;
                 break;
+            }
             case FN_QUIT:
                 *data_size = 0;
                 return buf_size;