avformat/nutdec: Check fields

Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6566001610719232

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 2c146406ea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2022-09-18 14:47:25 +02:00
parent c91ed5ee63
commit f8074b797f
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 5 additions and 0 deletions

View File

@ -280,6 +280,11 @@ static int decode_main_header(NUTContext *nut)
for (i = 0; i < 256;) {
int tmp_flags = ffio_read_varlen(bc);
int tmp_fields = ffio_read_varlen(bc);
if (tmp_fields < 0) {
av_log(s, AV_LOG_ERROR, "fields %d is invalid\n", tmp_fields);
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (tmp_fields > 0)
tmp_pts = get_s(bc);