diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-12-29 03:00:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-02-19 02:40:54 +0100 |
commit | 9143ddea0f160a739c380fd6912decf771b32bb0 (patch) | |
tree | 70e5fbd6610eeaab2af8f8fcf0c5fe5d054d70f8 | |
parent | 6fab791daade82f85234312577782e202323db4d (diff) | |
download | ffmpeg-9143ddea0f160a739c380fd6912decf771b32bb0.tar.gz |
avcodec/exr: Check buf_size more completely
Fixes: Out of heap array read
Fixes: 4683/clusterfuzz-testcase-minimized-6152313673613312
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 903be5e4f66268273dc6e3c42a7fdeaab32066ef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/exr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 292707cd0a..c1490e521a 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -849,7 +849,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, line_offset = AV_RL64(s->gb.buffer + jobnr * 8); // Check if the buffer has the required bytes needed from the offset - if (line_offset > buf_size - 8) + if (buf_size < 8 || line_offset > buf_size - 8) return AVERROR_INVALIDDATA; src = buf + line_offset + 8; @@ -858,7 +858,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, return AVERROR_INVALIDDATA; data_size = AV_RL32(src - 4); - if (data_size <= 0 || data_size > buf_size) + if (data_size <= 0 || data_size > buf_size - line_offset - 8) return AVERROR_INVALIDDATA; s->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); |