diff options
author | dartraiden <dartraiden@protonmail.com> | 2020-01-12 14:12:42 +0300 |
---|---|---|
committer | dartraiden <dartraiden@protonmail.com> | 2020-01-12 14:14:27 +0300 |
commit | 69d3b201c14db069ad0aef4b21e8efb45e21df9b (patch) | |
tree | 9c168030e03459dfe2d2d6cf64511321786b41f8 /libs/libcurl/src/parsedate.c | |
parent | dcb62e4830223c1f5233d90b855e74006fd0942b (diff) |
libcurl: update to 7.68
Diffstat (limited to 'libs/libcurl/src/parsedate.c')
-rw-r--r-- | libs/libcurl/src/parsedate.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libs/libcurl/src/parsedate.c b/libs/libcurl/src/parsedate.c index f4b18d091a..585d7ea404 100644 --- a/libs/libcurl/src/parsedate.c +++ b/libs/libcurl/src/parsedate.c @@ -587,6 +587,30 @@ time_t curl_getdate(const char *p, const time_t *now) return -1; } +/* Curl_getdate_capped() differs from curl_getdate() in that this will return + TIME_T_MAX in case the parsed time value was too big, instead of an + error. */ + +time_t Curl_getdate_capped(const char *p) +{ + time_t parsed = -1; + int rc = parsedate(p, &parsed); + + switch(rc) { + case PARSEDATE_OK: + if(parsed == -1) + /* avoid returning -1 for a working scenario */ + parsed++; + return parsed; + case PARSEDATE_LATER: + /* this returns the maximum time value */ + return parsed; + default: + return -1; /* everything else is fail */ + } + /* UNREACHABLE */ +} + /* * Curl_gmtime() is a gmtime() replacement for portability. Do not use the * gmtime_r() or gmtime() functions anywhere else but here. |