mirror of
https://github.com/curl/curl.git
synced 2026-08-06 15:36:14 +03:00
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.
This commit is contained in:
parent
63b7d8b8f4
commit
5e27c20870
9 changed files with 50 additions and 68 deletions
|
|
@ -1855,9 +1855,9 @@ static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data,
|
|||
}
|
||||
else if(!strncmp(cmd, "atime", 5) ||
|
||||
!strncmp(cmd, "mtime", 5)) {
|
||||
time_t date = Curl_getdate_capped(sshc->quote_path1);
|
||||
time_t date;
|
||||
bool fail = FALSE;
|
||||
if(date == -1) {
|
||||
if(Curl_getdate_capped(sshc->quote_path1, &date)) {
|
||||
failf(data, "incorrect date format for %.*s", 5, cmd);
|
||||
fail = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1390,16 +1390,16 @@ sftp_quote_stat(struct Curl_easy *data,
|
|||
}
|
||||
else if(!strncmp(cmd, "atime", 5) ||
|
||||
!strncmp(cmd, "mtime", 5)) {
|
||||
time_t date = Curl_getdate_capped(sshc->quote_path1);
|
||||
time_t date;
|
||||
bool fail = FALSE;
|
||||
|
||||
if(date == -1) {
|
||||
if(Curl_getdate_capped(sshc->quote_path1, &date)) {
|
||||
failf(data, "incorrect date format for %.*s", 5, cmd);
|
||||
fail = TRUE;
|
||||
}
|
||||
#if SIZEOF_TIME_T > SIZEOF_LONG
|
||||
if(date > 0xffffffff) {
|
||||
/* if 'long' cannot old >32-bit, this date cannot be sent */
|
||||
/* if 'long' cannot hold >32-bit, this date cannot be sent */
|
||||
failf(data, "date overflow");
|
||||
fail = TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue