Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2024 20:53:10 GMT
From:      Mateusz Piotrowski <0mp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f2ec4bd306ac - stable/14 - date: Correctly check outcome of mktime().
Message-ID:  <202405022053.442KrAnj040096@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by 0mp:

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

commit f2ec4bd306ac786222bd5a6522b45e762e968b31
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-04-28 17:12:58 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2024-05-02 20:52:37 +0000

    date: Correctly check outcome of mktime().
    
    X-MFC-With:     7b390cb63689
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D44982
    
    (cherry picked from commit dafb424b8d44c7fdc9cfe876a79aad05c438def0)
---
 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 62703c6d70ac..6b6e1f69cabc 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -347,7 +347,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?202405022053.442KrAnj040096>