summaryrefslogtreecommitdiff
path: root/libavcodec/exr.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-12-29 03:00:19 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-12-30 21:11:32 +0100
commitf2b83f4aba2b9e248fb62cdfffb0842332b0e068 (patch)
tree4d21d56be9640e94fcbe9cd315864ec74450a1bf /libavcodec/exr.c
parent1bc06771d83e2f6b049520dc3a5596ba9766dccb (diff)
downloadffmpeg-f2b83f4aba2b9e248fb62cdfffb0842332b0e068.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>
Diffstat (limited to 'libavcodec/exr.c')
-rw-r--r--libavcodec/exr.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index b4063f8fa4..7fa17ca887 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1062,7 +1062,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
line_offset = AV_RL64(s->gb.buffer + jobnr * 8);
if (s->is_tile) {
- if (line_offset > buf_size - 20)
+ if (buf_size < 20 || line_offset > buf_size - 20)
return AVERROR_INVALIDDATA;
src = buf + line_offset + 20;
@@ -1073,7 +1073,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
tileLevelY = AV_RL32(src - 8);
data_size = AV_RL32(src - 4);
- if (data_size <= 0 || data_size > buf_size)
+ if (data_size <= 0 || data_size > buf_size - line_offset - 20)
return AVERROR_INVALIDDATA;
if (tileLevelX || tileLevelY) { /* tile level, is not the full res level */
@@ -1106,7 +1106,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
uncompressed_size = td->channel_line_size * (uint64_t)td->ysize;/* uncompress size of the block */
} else {
- if (line_offset > buf_size - 8)
+ if (buf_size < 8 || line_offset > buf_size - 8)
return AVERROR_INVALIDDATA;
src = buf + line_offset + 8;
@@ -1116,7 +1116,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;
td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */