mirror of
https://github.com/openssh/openssh-portable.git
synced 2026-11-06 05:16:43 +00:00
upstream: ssh: use sentinel idiom for timegm(3) and mktime(3)
There is nothing wrong with times before the epoch, even -1, so use the idiom recently added to the CAVEATS section to figure out whether there was an error in the timegm() or mktime() calls. We should sweep the tree for this. If anyone is bored, feel free to beat me to it... ok deraadt djm OpenBSD-Commit-ID: e2b1721966dc782e776db5d6cfb18958534f9d4b
This commit is contained in:
1 parent
26a8c13e61
commit
3bee4a1a26
1 file changed
+5
-3
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: misc.c,v 1.213 2026/03/03 09:57:25 dtucker Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.214 2026/05/27 13:54:15 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
|
||||
@@ -2588,10 +2588,12 @@ parse_absolute_time(const char *s, uint64_t *tp)
|
||||
if ((cp = strptime(buf, fmt, &tm)) == NULL || *cp != '\0')
|
||||
return SSH_ERR_INVALID_FORMAT;
|
||||
if (is_utc) {
|
||||
if ((tt = timegm(&tm)) < 0)
|
||||
tm.tm_wday = -1;
|
||||
if ((tt = timegm(&tm)) == -1 && tm.tm_wday == -1)
|
||||
return SSH_ERR_INVALID_FORMAT;
|
||||
} else {
|
||||
if ((tt = mktime(&tm)) < 0)
|
||||
tm.tm_wday = -1;
|
||||
if ((tt = mktime(&tm)) == -1 && tm.tm_wday == -1)
|
||||
return SSH_ERR_INVALID_FORMAT;
|
||||
}
|
||||
/* success */
|
||||
|
||||
Reference in new issue
Block a user