1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avformat/avidec: Use av_sat_sub64() in check_stream_max_drift()

Fixes: signed integer overflow: 8833900919969684211 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 26726/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5669377724383232
Fixes: 27587/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6294562263531520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-10-31 11:54:16 +01:00
parent 1b19057396
commit 7d7ae68972

View File

@ -1691,18 +1691,19 @@ static int check_stream_max_drift(AVFormatContext *s)
AVIStream *ast = st->priv_data;
if (idx[i] && min_dts != INT64_MAX / 2) {
int64_t dts;
int64_t dts, delta_dts;
dts = av_rescale_q(st->internal->index_entries[idx[i] - 1].timestamp /
FFMAX(ast->sample_size, 1),
st->time_base, AV_TIME_BASE_Q);
delta_dts = av_sat_sub64(dts, min_dts);
max_dts = FFMAX(max_dts, dts);
max_buffer = FFMAX(max_buffer,
av_rescale(dts - min_dts,
av_rescale(delta_dts,
st->codecpar->bit_rate,
AV_TIME_BASE));
}
}
if (max_dts - min_dts > 2 * AV_TIME_BASE ||
if (av_sat_sub64(max_dts, min_dts) > 2 * AV_TIME_BASE ||
max_buffer > 1024 * 1024 * 8 * 8) {
av_free(idx);
return 1;