Commit 77abf314 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/mpsubdec: Check pts / duration before cast

Fixes: 3e+47 is outside the range of representable values of type 'int'
Fixes: 16057/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5691111307214848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4d4734bd
...@@ -83,13 +83,20 @@ static int mpsub_read_header(AVFormatContext *s) ...@@ -83,13 +83,20 @@ static int mpsub_read_header(AVFormatContext *s)
ff_subtitles_read_chunk(s->pb, &buf); ff_subtitles_read_chunk(s->pb, &buf);
if (buf.len) { if (buf.len) {
double ts = current_pts + start*multiplier;
sub = ff_subtitles_queue_insert(&mpsub->q, buf.str, buf.len, 0); sub = ff_subtitles_queue_insert(&mpsub->q, buf.str, buf.len, 0);
if (!sub) { if (!sub) {
res = AVERROR(ENOMEM); res = AVERROR(ENOMEM);
goto end; goto end;
} }
sub->pts = (int64_t)(current_pts + start*multiplier); if (!isfinite(ts) || ts < INT64_MIN || ts > INT64_MAX) {
sub->duration = (int)(duration * multiplier); avpriv_request_sample(s, "Invalid ts\n");
} else
sub->pts = (int64_t)ts;
if (!isfinite(duration) || duration * multiplier > INT_MAX || duration < 0) {
avpriv_request_sample(s, "Invalid duration\n");
} else
sub->duration = (int)(duration * multiplier);
current_pts += (start + duration) * multiplier; current_pts += (start + duration) * multiplier;
sub->pos = pos; sub->pos = pos;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment