1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avcodec/exr: Check preview psize

Fixes: signed integer overflow: 17121181824 * 538976288 cannot be represented in type 'long long'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5915330316206080

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 ac26712e35)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2022-09-10 23:54:17 +02:00
parent 8f483d42e0
commit 4e07d4a1ee
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -1951,9 +1951,12 @@ static int decode_header(EXRContext *s, AVFrame *frame)
"preview", 16)) >= 0) {
uint32_t pw = bytestream2_get_le32(gb);
uint32_t ph = bytestream2_get_le32(gb);
int64_t psize = 4LL * pw * ph;
uint64_t psize = pw * ph;
if (psize > INT64_MAX / 4)
return AVERROR_INVALIDDATA;
psize *= 4;
if (psize >= bytestream2_get_bytes_left(gb))
if ((int64_t)psize >= bytestream2_get_bytes_left(gb))
return AVERROR_INVALIDDATA;
bytestream2_skip(gb, psize);