]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: Use av_sat_sub64() in max_analyze_duration check
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 10 Nov 2020 21:27:47 +0000 (22:27 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 29 Jan 2021 18:36:46 +0000 (19:36 +0100)
Fixes: signed integer overflow: 9223372036854710272 - -541165944832 cannot be represented in type 'long'
Fixes: 27000/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5643670608674816
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index 9dab4fc96f7a8f15f5cb8e254e82a3979c412ed2..fb3299503e64be4c3db26e4bddddf1dfd3560413 100644 (file)
@@ -3864,8 +3864,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
             if (   t == 0
                 && st->codec_info_nb_frames>30
                 && st->internal->info->fps_first_dts != AV_NOPTS_VALUE
-                && st->internal->info->fps_last_dts  != AV_NOPTS_VALUE)
-                t = FFMAX(t, av_rescale_q(st->internal->info->fps_last_dts - st->internal->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
+                && st->internal->info->fps_last_dts  != AV_NOPTS_VALUE) {
+                int64_t dur = av_sat_sub64(st->internal->info->fps_last_dts, st->internal->info->fps_first_dts);
+                t = FFMAX(t, av_rescale_q(dur, st->time_base, AV_TIME_BASE_Q));
+            }
 
             if (analyzed_all_streams)                                limit = max_analyze_duration;
             else if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) limit = max_subtitle_analyze_duration;