diff mbox series

[FFmpeg-devel] avformat/utils: reorder duration computation to avoid overflow

Message ID 20200621170753.11770-1-michael@niedermayer.cc
State Accepted
Commit 10cc82c35baabbb07ffec3faccb04d8928c39e4c
Headers show
Series [FFmpeg-devel] avformat/utils: reorder duration computation to avoid overflow | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer June 21, 2020, 5:07 p.m. UTC
Fixes: signed integer overflow: 8 * 9223372036854774783 cannot be represented in type 'long'
Fixes: 23381/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4818340509122560

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer July 1, 2020, 9:31 a.m. UTC | #1
On Sun, Jun 21, 2020 at 07:07:53PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 8 * 9223372036854774783 cannot be represented in type 'long'
> Fixes: 23381/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4818340509122560
> 
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 45a4179552..807d9f10cb 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2782,7 +2782,7 @@  static void estimate_timings_from_bit_rate(AVFormatContext *ic)
                 st      = ic->streams[i];
                 if (   st->time_base.num <= INT64_MAX / ic->bit_rate
                     && st->duration == AV_NOPTS_VALUE) {
-                    duration = av_rescale(8 * filesize, st->time_base.den,
+                    duration = av_rescale(filesize, 8LL * st->time_base.den,
                                           ic->bit_rate *
                                           (int64_t) st->time_base.num);
                     st->duration = duration;