[FFmpeg-cvslog] avformat/mov: fix overflow in drift timestamp calculation

James Almer git at videolan.org
Thu Jan 30 16:35:49 EET 2025


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Jan 28 21:23:11 2025 -0300| [02958ab7156b4e14f1918f2b72c6d3678852698f] | committer: James Almer

avformat/mov: fix overflow in drift timestamp calculation

Fixes: signed integer overflow: 7803923888585309955 - -3407677434275325337 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 377736723/clusterfuzz-testcase-minimized-media_pipeline_integration_fuzzer-5052449500889088

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c016ce8e41..2c8be51063 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3541,7 +3541,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         current_dts += sc->stts_data[i].duration * (uint64_t)sample_count;
 
         if (current_dts > corrected_dts) {
-            int64_t drift = (current_dts - corrected_dts)/FFMAX(sample_count, 1);
+            int64_t drift = av_sat_sub64(current_dts, corrected_dts) / FFMAX(sample_count, 1);
             uint32_t correction = (sc->stts_data[i].duration > drift) ? drift : sc->stts_data[i].duration - 1;
             current_dts -= correction * (uint64_t)sample_count;
             sc->stts_data[i].duration -= correction;



More information about the ffmpeg-cvslog mailing list