mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 07:13:36 +02:00
ntpd: use the usual error check for timegm(3).
Straightforward change. The code could use some refactoring to avoid two consecutive timegm(3) calls on tm_tls. The layering is a bit strange here. ok deraadt henning job
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: constraint.c,v 1.60 2024/11/21 13:38:14 claudio Exp $ */
|
||||
/* $OpenBSD: constraint.c,v 1.61 2026/06/01 12:22:06 tb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
|
||||
@@ -1062,7 +1062,9 @@ httpsdate_request(struct httpsdate *httpsdate, struct timeval *when, int synced)
|
||||
*/
|
||||
notbefore = tls_peer_cert_notbefore(httpsdate->tls_ctx);
|
||||
notafter = tls_peer_cert_notafter(httpsdate->tls_ctx);
|
||||
if ((httptime = timegm(&httpsdate->tls_tm)) == -1)
|
||||
httpsdate->tls_tm.tm_wday = -1;
|
||||
if ((httptime = timegm(&httpsdate->tls_tm)) == -1 &&
|
||||
httpsdate->tls_tm.tm_wday == -1)
|
||||
goto fail;
|
||||
if (httptime <= notbefore) {
|
||||
if ((tm = gmtime(¬before)) == NULL)
|
||||
@@ -1114,8 +1116,12 @@ httpsdate_query(const char *addr, const char *port, const char *hostname,
|
||||
if (httpsdate_request(httpsdate, &when, synced) == -1)
|
||||
return (NULL);
|
||||
|
||||
/* Return parsed date as local time */
|
||||
httpsdate->tls_tm.tm_wday = -1;
|
||||
t = timegm(&httpsdate->tls_tm);
|
||||
if (t == -1 && httpsdate->tls_tm.tm_wday == -1) {
|
||||
httpsdate_free(httpsdate);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Report parsed Date: as "received time" */
|
||||
rectv->tv_sec = t;
|
||||
|
||||
Reference in New Issue
Block a user