From nobody Wed May 1 07:53:04 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VTq746NbVz5JPXk; Wed, 1 May 2024 07:53:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VTq745ZCLz4Vng; Wed, 1 May 2024 07:53:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714549984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OlBj1hK1zRMVTlYbFTmbJjoSF/zQK56aOu109P4aoa4=; b=BgYnLILRus3bneuYKaLeBZ0fD2nFL8Z9LWqVzxrxtmcBbbr/SmFL6UF7FBPqwDyLSH9Cet Mhy+44AuVSLD5/E0CcQcM5Nw9VRsy0PK9XKcK4JkTfZLKDIIwa4ROWiJxYw9qxb1BzVIU8 +t/krjALXtsuDnRsXv13Y4yMgfMANlEOldyScxxdUyjRKUD0GPBeV6cHlpuER+d8I6aixC hQTAnTaCnYqk33ncxxrXt6f+vpRtBEOeeh/egD/S1iLiUbUvOM+r+JNf/RV4v50XYG8gcn NdckHCUPdR5DcCgOurcMu0eU+h6TouT80qCOSfLUFXZ7sefUFCIYfvhUuCBQ+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714549984; a=rsa-sha256; cv=none; b=vUZRvKfHtbCBAXDufq8S1CENUx7AWWtChqdTiL2zYNXKzrPORbagUHFJ5y/KT1W6dH/TSa JRAoxwWrRLJRmHsloeFt/cYdLawqVX5SKcxCXfWv/skwAQtICii12fmQEwOlDhYOKHH/wO SP96ewg//xFX42Z+k5vhJ2hXIEcD6rhti9W+VhMcKPNgsCrL/Z2pbbCRcG+hXHj0r4kTnW Ggbqne3Cbw8l55MZBsHd9r4Yho4r80/EJwx3vUcnuHZHTZAAud7WcBSm6WMRrm6KuQSHF9 qjp6zbiTznpp5BBoDPs2bptTSDTj/Dub4/I09cKjTudt9PS9a3FUEGSze6FqzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714549984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OlBj1hK1zRMVTlYbFTmbJjoSF/zQK56aOu109P4aoa4=; b=GEW1NPeP0i5YV893LtaRKCuJHrFGXX10B3kJ/4nC6Xe2qcjsZFfKksFgQ13uTMgU85g1S9 LHzI2KUKC6X1ZvObujywt4jVfpOBQ3YeH6psLoP/LwO6LkgcLCpHtNZrGdlUU+rDHz8aX/ lxzYK9y91jO5vD0aDx5lngjjXzDMtWl0H/V3XSxK0Oo4eojTa6IuQV4qxEOGZB8xqcBx4C V4ZWyJDCuaMJ9u5ybTawx9L+ETB69PUnnlDEbh5eeWE6yLRiJKCHcxCBxw/6+8BzVEocEY DSmHFtMIJsN4EOI9CK7VtCrZmevFkX+jLDPT+j+AFEqrr+QyM0qFcQlCAXkpGA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VTq7459qLz19BS; Wed, 1 May 2024 07:53:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4417r41G081009; Wed, 1 May 2024 07:53:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4417r4M1081006; Wed, 1 May 2024 07:53:04 GMT (envelope-from git) Date: Wed, 1 May 2024 07:53:04 GMT Message-Id: <202405010753.4417r4M1081006@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 0fe60dc65572 - main - fattime: fix fattime to timespec conversion of dates beyond 2106-02-06 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0fe60dc65572f4d04992c97c0e262af5c50e7408 Auto-Submitted: auto-generated The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=0fe60dc65572f4d04992c97c0e262af5c50e7408 commit 0fe60dc65572f4d04992c97c0e262af5c50e7408 Author: Josef 'Jeff' Sipek AuthorDate: 2024-04-29 13:40:31 +0000 Commit: Toomas Soome CommitDate: 2024-05-01 04:56:41 +0000 fattime: fix fattime to timespec conversion of dates beyond 2106-02-06 It turns out that the only conversion issue was in fattime2timespec, where multiplying the number of seconds in a day by the number of days overflowed 32-bit unsigned int for dates beyond 2106-02-07 06:28:15. Casting one of the multiplicands as time_t forces a 64-bit multiplication on systems where time_t is 64-bits and produces no binary changes on the one remaining system with 32-bit time_t (namely i386). Since the code is now tested & fixed, this change removes the fixme comments. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44755 --- sys/kern/subr_fattime.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sys/kern/subr_fattime.c b/sys/kern/subr_fattime.c index 7b41b551eeef..569ee7f77112 100644 --- a/sys/kern/subr_fattime.c +++ b/sys/kern/subr_fattime.c @@ -63,11 +63,6 @@ * FAT timestamps have 7 bits for the year and starts at 1980, so * they can represent up to 2107 which means that the non-leap-year * 2100 must be handled. - * - * XXX: As long as time_t is 32 bits this is not relevant or easily - * XXX: testable. Revisit when time_t grows bigger. - * XXX: grepfodder: 64 bit time_t, y2100, y2.1k, 2100, leap year - * */ #include @@ -165,10 +160,7 @@ timespec2fattime(const struct timespec *tsp, int utc, uint16_t *ddp, } else { t2 -= T1980; - /* - * 2100 is not a leap year. - * XXX: a 32 bit time_t can not get us here. - */ + /* 2100 is not a leap year */ if (t2 >= ((2100 - 1980) / 4 * LYC + FEB)) t2++; @@ -242,17 +234,14 @@ fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, /* Month offset from leap-year cycle */ day += daytab[(dd >> 5) & 0x3f]; - /* - * 2100 is not a leap year. - * XXX: a 32 bit time_t can not get us here. - */ + /* 2100 is not a leap year */ if (day >= ((2100 - 1980) / 4 * LYC + FEB)) day--; /* Align with time_t epoch */ day += T1980; - tsp->tv_sec += DAY * day; + tsp->tv_sec += (time_t) DAY * day; if (!utc) tsp->tv_sec += utc_offset(); }