]> git.sesse.net Git - ffmpeg/commitdiff
rawdec: only exempt BIT0 with need_copy from buffer sanity check
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sat, 19 Dec 2015 22:45:06 +0000 (23:45 +0100)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sun, 20 Dec 2015 11:15:56 +0000 (12:15 +0100)
Otherwise the too small buffer is directly used in the frame, causing
segmentation faults, when trying to use the frame.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavcodec/rawdec.c

index 611178fc0d989fed54534aac42ea63bfda613290..50cee39aa68ea0051b3259e2b1927cbe79e58cd0 100644 (file)
@@ -257,7 +257,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         buf += buf_size - context->frame_size;
 
     len = context->frame_size - (avctx->pix_fmt==AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0);
-    if (buf_size < len && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0)) {
+    if (buf_size < len && ((avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0) || !need_copy)) {
         av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected frame_size %d\n", buf_size, len);
         av_buffer_unref(&frame->buf[0]);
         return AVERROR(EINVAL);