aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-04-25 20:45:10 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-11 21:23:49 +0200
commit090e2d16809e3b52fbc7d1e4a2d1c568f4d1c263 (patch)
tree6506ffa28319e2169417977a0fa05a5f0b5a8fd0
parent0602cf0ce3d9d3629bd9dca9756c9f8ca5d8c8b4 (diff)
downloadffmpeg-090e2d16809e3b52fbc7d1e4a2d1c568f4d1c263.tar.gz
avformat/realtextdec: Check the pts difference before using it for the duration computation
Fixes: signed integer overflow: 5404200000 - -9223372031709351616 cannot be represented in type 'long' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_REALTEXT_fuzzer-6737340551790592 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 fe12aa689003db9b07a6e1b837031dcc57a71435) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/realtextdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c
index 4f25754b9f..ba8cdfd196 100644
--- a/libavformat/realtextdec.c
+++ b/libavformat/realtextdec.c
@@ -111,10 +111,11 @@ static int realtext_read_header(AVFormatContext *s)
if (!merge) {
const char *begin = ff_smil_get_attr_ptr(buf.str, "begin");
const char *end = ff_smil_get_attr_ptr(buf.str, "end");
+ int64_t endi = end ? read_ts(end) : 0;
sub->pos = pos;
sub->pts = begin ? read_ts(begin) : 0;
- sub->duration = end ? (read_ts(end) - sub->pts) : duration;
+ sub->duration = (end && endi > sub->pts && endi - (uint64_t)sub->pts <= INT64_MAX) ? endi - sub->pts : duration;
}
}
av_bprint_clear(&buf);