summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-04 00:15:53 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-03-29 22:19:39 +0200
commit6dc6e1cce0ec0aadab27e8b3fd3fc87c93c3acd6 (patch)
tree6bbeb419dc755a805ff81ef66b899e170d11e44b /libavformat/utils.c
parent7b4510d2a875f666ed6d990f03331a3c60aca53f (diff)
avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()
Fixes: signed integer overflow: 136323327 * 281474976710656 cannot be represented in type 'long' Fixes: 30913/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5753392189931520 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 88f6f18f1f..dffc259ed8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3409,7 +3409,8 @@ void ff_rfps_calculate(AVFormatContext *ic)
// the check for tb_unreliable() is not completely correct, since this is not about handling
// an unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
// ipmovie.c produces.
- if (tb_unreliable(st->internal->avctx) && st->internal->info->duration_count > 15 && st->internal->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num)
+ if (tb_unreliable(st->internal->avctx) && st->internal->info->duration_count > 15 && st->internal->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num &&
+ st->internal->info->duration_gcd < INT64_MAX / st->time_base.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->internal->info->duration_gcd, INT_MAX);
if (st->internal->info->duration_count>1 && !st->r_frame_rate.num
&& tb_unreliable(st->internal->avctx)) {