aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-10-16 18:08:37 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:37:21 +0200
commitc8c0ed9e2bf8c26eec22bd2fb8c4daa1cf6f3e2c (patch)
tree4487b28f297afe6166d9e5c220a55abbd1ae5640
parent253b1ed27ef5a5b2a61d616d80a28d939972d3ab (diff)
downloadffmpeg-c8c0ed9e2bf8c26eec22bd2fb8c4daa1cf6f3e2c.tar.gz
avcodec/exr: Check limits to avoid overflow in delta computation
Fixes: signed integer overflow: 553590816 - -2145378049 cannot be represented in type 'int' Fixes: 26315/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5938755121446912 Fixes: 26340/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5644316208529408 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 6910e0f4e5c40b5b902e4dd87256327d860d53f5) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/exr.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 6e896d9760..4c70e7b054 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1520,15 +1520,27 @@ static int decode_header(EXRContext *s, AVFrame *frame)
continue;
} else if ((var_size = check_header_variable(s, "dataWindow", "box2i",
31)) >= 0) {
+ int xmin, ymin, xmax, ymax;
if (!var_size) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
- s->xmin = bytestream2_get_le32(&s->gb);
- s->ymin = bytestream2_get_le32(&s->gb);
- s->xmax = bytestream2_get_le32(&s->gb);
- s->ymax = bytestream2_get_le32(&s->gb);
+ xmin = bytestream2_get_le32(&s->gb);
+ ymin = bytestream2_get_le32(&s->gb);
+ xmax = bytestream2_get_le32(&s->gb);
+ ymax = bytestream2_get_le32(&s->gb);
+
+ if (xmin > xmax || ymin > ymax ||
+ (unsigned)xmax - xmin >= INT_MAX ||
+ (unsigned)ymax - ymin >= INT_MAX) {
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+ s->xmin = xmin;
+ s->xmax = xmax;
+ s->ymin = ymin;
+ s->ymax = ymax;
s->xdelta = (s->xmax - s->xmin) + 1;
s->ydelta = (s->ymax - s->ymin) + 1;