aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rawdec.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-03-06 16:08:10 -0800
committerReinhard Tartler <siretart@tauware.de>2012-04-01 18:33:29 +0200
commit4924520513d06b4d9169a1d3e0374d5a48bc02e0 (patch)
treef8c1dce590ab46b8e6cdc270c68d140548e26a36 /libavcodec/rawdec.c
parentf2e412d050ae9a0dcdea515f1c02620c6dcf8c47 (diff)
downloadffmpeg-4924520513d06b4d9169a1d3e0374d5a48bc02e0.tar.gz
raw: move buffer size check up.
This way, it protects against overreads for 4bpp/2bpp content also. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit cc5dd632cecc5114717d0b90f8c2be162b1c6ee8) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec/rawdec.c')
-rw-r--r--libavcodec/rawdec.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 5e8e6c4c43..05a032e62c 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -127,6 +127,9 @@ static int raw_decode(AVCodecContext *avctx,
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts;
+ if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
+ return -1;
+
//2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
if (context->buffer) {
int i;
@@ -151,9 +154,6 @@ static int raw_decode(AVCodecContext *avctx,
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->length;
- if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
- return -1;
-
avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
(avctx->pix_fmt!=PIX_FMT_PAL8 &&