From patchwork Sat Apr 15 22:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41195 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1411928pzb; Sat, 15 Apr 2023 15:06:22 -0700 (PDT) X-Google-Smtp-Source: AKy350b0glabGag4ioFMKXLQpnPR5IHksUYcLdtslKnoJRK2bFlXcB5x6ha9UCw8QmELjrKM2v0E X-Received: by 2002:a17:907:8a21:b0:94f:3521:394 with SMTP id sc33-20020a1709078a2100b0094f35210394mr1771294ejc.51.1681596382269; Sat, 15 Apr 2023 15:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596382; cv=none; d=google.com; s=arc-20160816; b=AQkzoJtM9FnebRde1Ec33koJd9pIUPOc2H+TlLnSG9DbB15r04/Iq1m0fdiqMlhzX/ jMAuuwQhSF1CJNOErzmkh2FHeinJwiy8Ui99wYSaghYsXvDRnczZN0jNyojuFbgwkIJB 9V5Huw9cZ/0JAaXU4I2nWtkCFtlFiCpwM9/lqkPdvOBg1zlmD4j4wjIVsRegECEaVEIh N+j7Za0qni/2zl5ezXQjCR20bdAdt6D2tMqqqGq/uJQZFydIoT7VRdaQj+tOrlcjoCCb YgYfRWr9ggH6QmIrBnEa8raRfQyYf6izaXN2rFG54WHzD5fhtK2B4i76/c6DDEj1ovtb tgEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=AtYxrHXEK4pbXBJhf64BcUyu/kBybE+zvJpsIXEUUBM=; b=PPiSPh8x7KvTzbph/qQoltWROxAreKfv5Rm90JKv0ilO9d1vFQeECIvIMHcYSe59m1 5GMBAGNIOmodBW3XyiQz5s9GBrGxkUJdaSZ0ZjJQKhXlNAbhhU9AsrUjg4mBox64yJ78 gW9zWbsCB2R5ZBVhXa+PvqeBg74dv0ySj9JNVvdt2Ehw4MsWcgQX1G0w0jlgx69X2R+Q I4f7locVpz/lSNztT+OuzmG7x1T96zWLyvugCpCtoqRrITOAZEtjjHbdG1J2BxYEDkYp +/O9jVaNcm/yKfY7bvIL9sHz/K/gAjYzmGuO9EghdLxRSJV7/5NypNFwZsBnlIjXP8RZ DXEQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fd10-20020a1709072a0a00b0094f41b55cb8si578275ejc.675.2023.04.15.15.06.21; Sat, 15 Apr 2023 15:06:22 -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 A1EB168BDFB; Sun, 16 Apr 2023 01:06:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D24368B36D for ; Sun, 16 Apr 2023 01:06:10 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5BA34E8A15; Sun, 16 Apr 2023 00:05:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HN-YWDM_JXvt; Sun, 16 Apr 2023 00:05:25 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 48238E8A01; Sun, 16 Apr 2023 00:05:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:54 +0200 Message-Id: <20230415220558.16122-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avformat/mov: restrict unix timestamp hack to version 0 mdhd/mvhd X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8b7wsAKf04rD Commit 23eeffcd48a15e73fb2649b712870b6d101c5471 added a hack to support invalid files where the creation date was encoded as a classic unix timestamp. Let's reduce the scope of the hack by only applying it to version 0 mdhd/mvhd atoms. Also warn the user of such possibly broken files. Signed-off-by: Marton Balint --- libavformat/mov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5d00ff6e8b..1b3c1d7683 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1524,10 +1524,13 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction } else { time = avio_rb32(pb); avio_rb32(pb); /* modification time */ + if (time > 0 && time < 2082844800) { + av_log(c->fc, AV_LOG_WARNING, "Detected creation time before 1970, parsing as unix timestamp.\n"); + time += 2082844800; + } } if (time) { - if (time >= 2082844800) - time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ + time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ if ((int64_t)(time * 1000000ULL) / 1000000 != time) { av_log(c->fc, AV_LOG_DEBUG, "creation_time is not representable\n");