diff mbox series

[FFmpeg-devel,2/2] avcodec/exr: x/ymax cannot be INT_MAX

Message ID 20210421123118.17901-2-michael@niedermayer.cc
State Accepted
Commit 48342aa0750f83006582d1598b5f22297f6dbf83
Headers show
Series [FFmpeg-devel,1/2] avformat/mov: Avoid undefined overflow in time_offset calculation | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer April 21, 2021, 12:31 p.m. UTC
The code uses x/ymax + 1 so the maximum is INT_MAX-1

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 33158/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5545462457303040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/exr.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Niedermayer May 27, 2021, 3:44 p.m. UTC | #1
On Wed, Apr 21, 2021 at 02:31:18PM +0200, Michael Niedermayer wrote:
> The code uses x/ymax + 1 so the maximum is INT_MAX-1
> 
> Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
> Fixes: 33158/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5545462457303040
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/exr.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 49c4774145..59403fd1f5 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1795,6 +1795,7 @@  static int decode_header(EXRContext *s, AVFrame *frame)
             ymax   = bytestream2_get_le32(gb);
 
             if (xmin > xmax || ymin > ymax ||
+                ymax == INT_MAX || xmax == INT_MAX ||
                 (unsigned)xmax - xmin >= INT_MAX ||
                 (unsigned)ymax - ymin >= INT_MAX) {
                 ret = AVERROR_INVALIDDATA;