summaryrefslogtreecommitdiff
path: root/lib/vssh
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-08-17 10:51:07 +0200
committerDaniel Stenberg <daniel@haxx.se>2022-08-18 00:02:09 +0200
commitc988ec9f41060144e175b519f9017c569ac8d3db (patch)
treea93091047cd4ff63a6a038501c969622e3d871df /lib/vssh
parent5357686fdf2886ff98526982137827d4e1a489e3 (diff)
downloadcurl-c988ec9f41060144e175b519f9017c569ac8d3db.tar.gz
libssh: make atime/mtime date overflow return error
Closes #9328
Diffstat (limited to 'lib/vssh')
-rw-r--r--lib/vssh/libssh.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
index c2f71d030..e0d9d71ae 100644
--- a/lib/vssh/libssh.c
+++ b/lib/vssh/libssh.c
@@ -2911,47 +2911,34 @@ static void sftp_quote_stat(struct Curl_easy *data)
}
sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID;
}
- else if(strncasecompare(cmd, "atime", 5)) {
+ else if(strncasecompare(cmd, "atime", 5) ||
+ strncasecompare(cmd, "mtime", 5)) {
time_t date = Curl_getdate_capped(sshc->quote_path1);
+ bool fail = FALSE;
if(date == -1) {
- Curl_safefree(sshc->quote_path1);
- Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect access date format");
- state(data, SSH_SFTP_CLOSE);
- sshc->nextstate = SSH_NO_STATE;
- sshc->actualcode = CURLE_QUOTE_ERROR;
- return;
+ failf(data, "incorrect date format for %.*s", 5, cmd);
+ fail = TRUE;
}
#if SIZEOF_TIME_T > 4
- if(date > 0xffffffff)
- ; /* avoid setting a capped time */
- else
-#endif
- {
- sshc->quote_attrs->atime = (uint32_t)date;
- sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
+ else if(date > 0xffffffff) {
+ failf(data, "date overflow");
+ fail = TRUE; /* avoid setting a capped time */
}
- }
- else if(strncasecompare(cmd, "mtime", 5)) {
- time_t date = Curl_getdate_capped(sshc->quote_path1);
- if(date == -1) {
+#endif
+ if(fail) {
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect modification date format");
state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
}
-#if SIZEOF_TIME_T > 4
- if(date > 0xffffffff)
- ; /* avoid setting a capped time */
- else
-#endif
- {
+ if(strncasecompare(cmd, "atime", 5))
+ sshc->quote_attrs->atime = (uint32_t)date;
+ else /* mtime */
sshc->quote_attrs->mtime = (uint32_t)date;
- sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
- }
+
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
}
/* Now send the completed structure... */