Download raw body.
ntpd timegm error checks
OK
On Sun, May 31, 2026 at 12:23:26PM +0200, Theo Buehler wrote:
> Another rather straightforward conversion, removing a confusing comment
> that would become a bit more confusing.
>
> As visible in the diff, tls_tm is parsed twice in a row, where the
> second (rather the first) parse was added with the manual constraints
> checking in 2019. The layering is a bit strange here.
>
> Index: constraint.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ntpd/constraint.c,v
> diff -u -p -r1.60 constraint.c
> --- constraint.c 21 Nov 2024 13:38:14 -0000 1.60
> +++ constraint.c 31 May 2026 10:14:09 -0000
> @@ -1062,7 +1062,9 @@ httpsdate_request(struct httpsdate *http
> */
> 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
> 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;
>
ntpd timegm error checks