From 5649b212979de21f52424bd22c45c3e8dcbb7448 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 20 Mar 2026 14:55:53 +0100 Subject: [PATCH] curlx_now(), prevent zero timestamp As code checks `curltime` values for zero and interprets this as not-initialized or "forever" in several places, make sure `curlx_now()` never returns a zero timestamp. Closes #21034 --- lib/curlx/timeval.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/curlx/timeval.c b/lib/curlx/timeval.c index 435804c299..2363e60839 100644 --- a/lib/curlx/timeval.c +++ b/lib/curlx/timeval.c @@ -166,6 +166,8 @@ void curlx_pnow(struct curltime *pnow) */ pnow->tv_sec = time(NULL); pnow->tv_usec = 0; + if(!pnow->tv_sec) /* avoid a `now` fully zero */ + pnow->tv_usec = 1; } #endif