Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 8024/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5109204648984576
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 424a81df107b63a166894a4aee3d27702ae3f459)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -234,11 +234,11 @@ static int decode_aiff_header(AVCodecContext *avctx, const uint8_t *header, |
234 | 234 |
|
235 | 235 |
while (bytestream2_get_le32(&gb) != MKTAG('C', 'O', 'M', 'M')) { |
236 | 236 |
len = bytestream2_get_be32(&gb); |
237 |
- bytestream2_skip(&gb, len + (len & 1)); |
|
238 |
- if (len < 0 || bytestream2_get_bytes_left(&gb) < 18) { |
|
237 |
+ if (len < 0 || bytestream2_get_bytes_left(&gb) < 18LL + len + (len&1)) { |
|
239 | 238 |
av_log(avctx, AV_LOG_ERROR, "no COMM chunk found\n"); |
240 | 239 |
return AVERROR_INVALIDDATA; |
241 | 240 |
} |
241 |
+ bytestream2_skip(&gb, len + (len & 1)); |
|
242 | 242 |
} |
243 | 243 |
len = bytestream2_get_be32(&gb); |
244 | 244 |
|