git: dafb424b8d44 - main - date: Correctly check outcome of mktime().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 28 Apr 2024 17:13:12 UTC
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;