parsedate: make Curl_getdate_capped able to return epoch

By returning error separately on parse errors and avoiding magic
numbers, this function can now return 0 or -1 as proper dates when such
a date string is provided.

Closes #18445
This commit is contained in:
Daniel Stenberg 2025-09-01 16:36:53 +02:00
parent 4d040c71d7
commit f8e6e11725
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 50 additions and 68 deletions

View file

@ -187,13 +187,13 @@ static CURLcode altsvc_add(struct altsvcinfo *asi, const char *line)
else {
struct altsvc *as;
char dbuf[MAX_ALTSVC_DATELEN + 1];
time_t expires;
time_t expires = 0;
/* The date parser works on a null-terminated string. The maximum length
is upheld by curlx_str_quotedword(). */
memcpy(dbuf, curlx_str(&date), curlx_strlen(&date));
dbuf[curlx_strlen(&date)] = 0;
expires = Curl_getdate_capped(dbuf);
Curl_getdate_capped(dbuf, &expires);
as = altsvc_create(&srchost, &dsthost, &srcalpn, &dstalpn,
(size_t)srcport, (size_t)dstport);
if(as) {