]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mov: Use av_mul_q() to avoid integer overflows
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 22 Nov 2020 18:13:01 +0000 (19:13 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 4 Feb 2021 22:34:29 +0000 (23:34 +0100)
Fixes: signed integer overflow: 538976288 * 538976288 cannot be represented in type 'int'
Fixes: 27473/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5758978289827840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index ad0b9a58d3568219ab3cdebe9e4bc323ad1f574b..8eacf2cc0489674bcd227228825ecf7d9323f156 100644 (file)
@@ -2354,12 +2354,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
             if (tmcd_ctx->tmcd_flags & 0x0008) {
                 int timescale = AV_RB32(st->codecpar->extradata + 8);
                 int framedur = AV_RB32(st->codecpar->extradata + 12);
-                st->avg_frame_rate.num *= timescale;
-                st->avg_frame_rate.den *= framedur;
+                st->avg_frame_rate = av_mul_q(st->avg_frame_rate, (AVRational){timescale, framedur});
 #if FF_API_LAVF_AVCTX
 FF_DISABLE_DEPRECATION_WARNINGS
-                st->codec->time_base.den *= timescale;
-                st->codec->time_base.num *= framedur;
+                st->codec->time_base = av_mul_q(st->codec->time_base , (AVRational){framedur, timescale});
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
             }