Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Apr 2024 17:13:12 GMT
From:      Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: dafb424b8d44 - main - date: Correctly check outcome of mktime().
Message-ID:  <202404281713.43SHDCea006959@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=dafb424b8d44c7fdc9cfe876a79aad05c438def0

commit dafb424b8d44c7fdc9cfe876a79aad05c438def0
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-04-28 17:12:58 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-04-28 17:12:58 +0000

    date: Correctly check outcome of mktime().
    
    X-MFC-With:     7b390cb63689
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D44982
---
 bin/date/date.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bin/date/date.c b/bin/date/date.c
index 718c94601dd6..3ce9ee3235fb 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -334,7 +334,9 @@ setthetime(const char *fmt, const char *p, int jflag, struct timespec *ts)
 	}
 
 	/* convert broken-down time to GMT clock time */
-	if ((ts->tv_sec = mktime(lt)) == -1)
+	lt->tm_yday = -1;
+	ts->tv_sec = mktime(lt);
+	if (lt->tm_yday == -1)
 		errx(1, "nonexistent time");
 	ts->tv_nsec = 0;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404281713.43SHDCea006959>