aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2024-04-28 17:12:58 +0000
committerMateusz Piotrowski <0mp@FreeBSD.org>2024-05-02 20:52:37 +0000
commitf2ec4bd306ac786222bd5a6522b45e762e968b31 (patch)
tree93418f92d5322ab23c4c8d325431f904d8f4159f
parent4fd988e652e5045f73df0794bfba870c04d39830 (diff)
downloadsrc-f2ec4bd306ac786222bd5a6522b45e762e968b31.tar.gz
src-f2ec4bd306ac786222bd5a6522b45e762e968b31.zip
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)
-rw-r--r--bin/date/date.c4
1 files changed, 3 insertions, 1 deletions
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;