aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-02-23 12:22:40 -0800
committerRonald S. Bultje <rsbultje@gmail.com>2012-02-24 07:28:43 -0800
commitab492ca2ab105aeb24d955f3f03756bdb3139ee1 (patch)
treed7ef9db935946f0c1c2bc61df5f72f8415f01aa2 /libavcodec/mjpegdec.c
parent46b3fbc30b7aaf7fdd52391734cfd6d93af8720a (diff)
downloadffmpeg-ab492ca2ab105aeb24d955f3f03756bdb3139ee1.tar.gz
mjpeg: abort decoding if packet is too large.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 27c47e9109..47a85cb598 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1458,6 +1458,10 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
/* EOF */
if (start_code < 0) {
goto the_end;
+ } else if (unescaped_buf_size > (1U<<29)) {
+ av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
+ start_code, unescaped_buf_ptr, buf_size);
+ return AVERROR_INVALIDDATA;
} else {
av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
start_code, buf_end - buf_ptr);