avformat/sbgdec: Check for negative duration or un-representable end pts

Fixes: signed integer overflow: 9230955872951340 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6330481893572608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2023-10-01 00:30:39 +02:00
parent c7fb4d0eb6
commit 9b00b5734d
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 7 additions and 0 deletions

View File

@ -1447,6 +1447,13 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
st->duration = script.end_ts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE :
av_rescale(script.end_ts - script.start_ts,
sbg->sample_rate, AV_TIME_BASE);
if (st->duration != AV_NOPTS_VALUE && (
st->duration < 0 || st->start_time > INT64_MAX - st->duration)) {
r = AVERROR_INVALIDDATA;
goto fail;
}
sti->cur_dts = st->start_time;
r = encode_intervals(&script, st->codecpar, &inter);
if (r < 0)