From patchwork Mon Aug 20 20:03:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Hubinette X-Patchwork-Id: 10039 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp2907721jap; Mon, 20 Aug 2018 13:03:54 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzaaN1iuErX7WsnBR8gFQCFjWGYNaXkDWXNfmkFQA8LBE4Y19N+pOCBjQwZy4rrCFn7/09/ X-Received: by 2002:a1c:d702:: with SMTP id o2-v6mr26394339wmg.115.1534795434479; Mon, 20 Aug 2018 13:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534795434; cv=none; d=google.com; s=arc-20160816; b=kE0xychkHi0gB8KjnlCeQZENqnOixOd/uUoxcUe3E4y1+a9p63uySEvkxhWyFNeY9R 4u/FZUXPUu0LqPFIYmiIIPYc/vJOUY4iPoGN/BFsblsVkXne1LdUZjAiJrHZkC9iQvzi UN8Aatmjd4HPO0DeK5hEYF7AO3+sYYsrzqNTvBE5CYN5DlN1tQrHUpi7dI5rMusaBT6r QPtkaW5v896k7Cm0COd4N+bJKgWz1L5ON+WVnqbIyyHitl0JX3hxAWthpf3L6yeikTn2 KP5pEugt94Z6CKP7qwqMNWiI9MDLiGAX6PYHbIkH0DodmN0P85zPkGGedP1U5E7tpc/A 8GVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=lEfSnZhVc85NP7u/URFYvm9Wl8e04fG+LG1u59YdnoE=; b=oN0N1MEUCqZ5UnCQwRChcrON0gnMXrPe80V9eW481GjyYF2RzqbHEzh3JrSYbiOtd0 dWkI53phR3RYivslPRcj5cFQxkzqQrfGdV4YVWPY4PO2Fhj6HpZOLGak/dO02Ap5YRDm hzZ76UyKTDuoBtAvldaJakUSK74ugzjGoXnrV1EQYvwdmypis3EGrXlWQ66uzLAlTEij v4mPJoMAbZ/oq9d3Lh3HRHzaIdshwOpbI4G3T4mvlvHzoIUk3SluXjbbH2LP3xBytMgn Qi/QKV6lsQe7EuNF7U8EpKdKu8Z0ADkCiZN3V5KLIE5r02t9Wo8cXr+nXwegEc2YrWvk JnKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=c18evpOA; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i70-v6si379283wmf.171.2018.08.20.13.03.53; Mon, 20 Aug 2018 13:03:54 -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; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=c18evpOA; 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 84E24689950; Mon, 20 Aug 2018 23:03:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb0-f196.google.com (mail-yb0-f196.google.com [209.85.213.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1EB0D680160 for ; Mon, 20 Aug 2018 23:03:18 +0300 (EEST) Received: by mail-yb0-f196.google.com with SMTP id o17-v6so5091702yba.2 for ; Mon, 20 Aug 2018 13:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=cSdnU37RfYfnbWPg3s/LnWfA+EF/+dHBfp93A7epznM=; b=c18evpOAGYD9ml5wO0flLQP5f2nkg01cFvP3KJrmoUaJ7eb1v3knjr4XAl5MsumUYa UgElUuI8t/+cqBSCRFHOaX5WK6fdUWS560d4E5ZOhC6hp7g7W9SeFLNMLWfpeojmx0dE 3De3sW0AT8wchUCqP5rVU1TpUU96agqw5yMDP9IIb1BkU1RhVZtK+5tFqZz6Cn8KxaYI c4VCVW2xDCz6BlLAcFvCsQVaePwDojPuDSiXuH5KTREEZqiwMpQaUke8PaPchObcn7VR 6GPB1LKf0Lide81eUSqMUy/zq5TnCtWYJe5PIN5OBznu3rThl7WGlkjhdgw+wogqBHTT IodA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=cSdnU37RfYfnbWPg3s/LnWfA+EF/+dHBfp93A7epznM=; b=H6YdXO4MgvIlmUbvCR6GmMHs+d2VeG0aQ/ad/T1TBBcNI/DFFt+oosNvr1a0RxfgUc DZuZQq7ALifW6UktJ3+crs//5N7ycTo77fe3nfiMPCp+bdEbKnWPymZ9Gqxo/zzeUCvM Pb4ld3Kaip11LtOlL4FAtNHSSw9cp7wNLdjofUYIWdv5Bgp4DosoLsDlxq/l8/guTH/Y A+A0CxmncCzg57eHfMx2+HrW1Mk/ICng+Baxb79EezfrppRZgO3s5juD43hODLk9nJOO cd+ZN1fK0ySQvuGoyvW307r4Ytsd8S+LCD0SUceaIU7++eNP0SRCmAKMykeP65WsY16s VMRA== X-Gm-Message-State: AOUpUlH/6b0ge0PJ964hVNQqaVB4eGHfVvonC5u6srK73Az/bZZ21xmw oBtyWt+WiVLLeEphEu1tWlm8wDFsWr4F10EYbmi01WTC X-Received: by 2002:a25:ddc5:: with SMTP id u188-v6mr20705553ybg.32.1534795423346; Mon, 20 Aug 2018 13:03:43 -0700 (PDT) MIME-Version: 1.0 References: <20180718105515.GD4859@michaelspb> <20180730235339.GY19650@michaelspb> In-Reply-To: <20180730235339.GY19650@michaelspb> From: Fredrik Hubinette Date: Mon, 20 Aug 2018 13:03:31 -0700 Message-ID: To: ffmpeg-devel X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] Avoid undefined behavior when start_time_text is -1<<63 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" Ok, let's use cast, new patch attached. On Mon, Jul 30, 2018 at 4:53 PM Michael Niedermayer wrote: > On Mon, Jul 30, 2018 at 01:49:24PM -0700, Fredrik Hubinette wrote: > > Is casting a negative integer to unsigned defined behavior? > > yes > > 6.3.1.3 Signed and unsigned integers > > 2 Otherwise, if the new type is unsigned, the value is converted by > repeatedly adding or > subtracting one more than the maximum value that can be represented in > the new type > until the value is in the range of the new type.49) > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > I do not agree with what you have to say, but I'll defend to the death your > right to say it. -- Voltaire > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From e8f3a5a4ff9b89b33f4067c7aa735fff9895333e Mon Sep 17 00:00:00 2001 From: Fredrik Hubinette Date: Mon, 20 Aug 2018 12:59:32 -0700 Subject: [PATCH] avoid undefined integer overflow behavior --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index fcd4328587..b0b5e164a6 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2666,7 +2666,7 @@ static void update_stream_timings(AVFormatContext *ic) duration = FFMAX(duration, duration1); } } - if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text < AV_TIME_BASE)) + if (start_time == INT64_MAX || (start_time > start_time_text && start_time - (uint64_t)start_time_text < AV_TIME_BASE)) start_time = start_time_text; else if (start_time > start_time_text) av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream starttime %f\n", start_time_text / (float)AV_TIME_BASE); -- 2.18.0.865.gffc8e1a3cd6-goog