From patchwork Sat Sep 24 11:10:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 699 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1023222vsd; Sat, 24 Sep 2016 04:10:47 -0700 (PDT) X-Received: by 10.28.136.197 with SMTP id k188mr7050058wmd.54.1474715447763; Sat, 24 Sep 2016 04:10:47 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e3si391018wmg.23.2016.09.24.04.10.46; Sat, 24 Sep 2016 04:10:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 597BF689D04; Sat, 24 Sep 2016 14:10:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (vie01a-dmta-pe04-3.mx.upcmail.net [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14E6D689AD0 for ; Sat, 24 Sep 2016 14:10:21 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bnkqq-0007ZA-RV for ffmpeg-devel@ffmpeg.org; Sat, 24 Sep 2016 13:10:36 +0200 Received: from [192.168.1.3] ([80.110.107.246]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id nPAb1t00i5Jzyoo01PAcp9; Sat, 24 Sep 2016 13:10:36 +0200 X-SourceIP: 80.110.107.246 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Sat, 24 Sep 2016 13:10:35 +0200 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201609241310.35616.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]lavf/utils: Avoid an overflow for huge negative durations. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi! Attached patch hopefully fixes ticket #5135. Please review, Carl Eugen From 12a33bb9d5475701009a60af79fa7699416b50e7 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 24 Sep 2016 13:07:39 +0200 Subject: [PATCH] lavf/utils: Avoid an overflow for huge negative durations. Fixes ticket #5135. --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 93ea6ff..3e0f57d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2547,7 +2547,7 @@ static void update_stream_timings(AVFormatContext *ic) end_time1 = av_rescale_q_rnd(st->duration, st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); - if (end_time1 != AV_NOPTS_VALUE && start_time1 <= INT64_MAX - end_time1) { + if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) { end_time1 += start_time1; end_time = FFMAX(end_time, end_time1); }