[FFmpeg-cvslog] avformat/utils: check dts/duration to be representable before using them

Michael Niedermayer git at videolan.org
Fri Jun 18 22:15:12 EEST 2021


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr 18 22:39:30 2021 +0200| [71b264c8fa70821330df9c71f238d5aa1eef5a7d] | committer: Michael Niedermayer

avformat/utils: check dts/duration to be representable before using them

Fixes: signed integer overflow: 6854513951393103890 + 3427256975738527712 cannot be represented in type 'long'
Fixes: 32936/clusterfuzz-testcase-minimized-ffmpeg_dem_R3D_fuzzer-5236914752978944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit bf4e7ec8257fd24a12327c7fa14e322028250be4)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71b264c8fa70821330df9c71f238d5aa1eef5a7d
---

 libavformat/utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index f341346200..5a70478a57 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1208,7 +1208,9 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
             (pktl->pkt.dts == AV_NOPTS_VALUE ||
              pktl->pkt.dts == st->first_dts ||
              pktl->pkt.dts == RELATIVE_TS_BASE) &&
-            !pktl->pkt.duration) {
+            !pktl->pkt.duration &&
+            av_sat_add64(cur_dts, duration) == cur_dts + (uint64_t)duration
+        ) {
             pktl->pkt.dts = cur_dts;
             if (!st->internal->avctx->has_b_frames)
                 pktl->pkt.pts = cur_dts;



More information about the ffmpeg-cvslog mailing list