From patchwork Fri Oct 12 01:40:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10643 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CC7F4441001 for ; Fri, 12 Oct 2018 04:43:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 10F0568A393; Fri, 12 Oct 2018 04:43:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe08-3.mx.upcmail.net (vie01a-dmta-pe08-3.mx.upcmail.net [84.116.36.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A90C68A316 for ; Fri, 12 Oct 2018 04:43:22 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gAmUS-0006Nf-Kp for ffmpeg-devel@ffmpeg.org; Fri, 12 Oct 2018 03:43:44 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id mRjc1y00b0S5wYM01RjdH1; Fri, 12 Oct 2018 03:43:37 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 12 Oct 2018 03:40:21 +0200 Message-Id: <20181012014021.9579-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181012014021.9579-1-michael@niedermayer.cc> References: <20181012014021.9579-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/utils: Fix long overflow in compute_pkt_fields() 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 Cc: Thomas Guilbert Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Thomas Guilbert If ever we have a negative last_IP_duration, we can end up with a long overflow. This makes sure we use pkt->duration instead of last_IP_duration if last_IP_duration is negative. Fixes: compute_pkt_usan --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index fa3699daef..2c965a7fb2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1352,7 +1352,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* This is tricky: the dts must be incremented by the duration * of the frame we are displaying, i.e. the last I- or P-frame. */ - if (st->last_IP_duration == 0) + if (st->last_IP_duration <= 0) st->last_IP_duration = pkt->duration; if (pkt->dts != AV_NOPTS_VALUE) st->cur_dts = pkt->dts + st->last_IP_duration;