aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-09-21 18:14:03 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-15 12:25:46 +0100
commit9462ca109fbb8dd9d6b1ec0aa2a2403db3395e82 (patch)
tree139f47aa3edd14d8f71753e49ce2515a1db151a5
parent3e5316bf2f5c7b58846d54d05b868e188e6778cf (diff)
downloadffmpeg-9462ca109fbb8dd9d6b1ec0aa2a2403db3395e82.tar.gz
avcodec/sunrast: Check that the input is large enough for the maximally compressed image
Fixes: Timeout (17sec -> 15ms) Fixes: 17224/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SUNRAST_fuzzer-5663218491457536 Fixes: 17224/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SUNRAST_fuzzer-5735590015795200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit bf0ba75c4a9231ed62afe60bed5bde2728971e30) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/sunrast.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index 98bc4ffa63..e1ec8a0832 100644
--- a/libavcodec/sunrast.c
+++ b/libavcodec/sunrast.c
@@ -100,7 +100,11 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
if (ret < 0)
return ret;
- if (buf_end - buf < maplength)
+ /* scanlines are aligned on 16 bit boundaries */
+ len = (depth * w + 7) >> 3;
+ alen = len + (len & 1);
+
+ if (buf_end - buf < maplength + (len * h) * 3 / 256)
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
@@ -136,10 +140,6 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
stride = p->linesize[0];
}
- /* scanlines are aligned on 16 bit boundaries */
- len = (depth * w + 7) >> 3;
- alen = len + (len & 1);
-
if (type == RT_BYTE_ENCODED) {
int value, run;
uint8_t *end = ptr + h * stride;