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
This commit is contained in:
Stefan Eissing 2026-03-20 14:55:53 +01:00 committed by Daniel Stenberg
parent 7e0a9b309c
commit 5649b21297
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -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