summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-08-16 16:29:15 +0200
committerDaniel Stenberg <daniel@haxx.se>2022-08-16 23:16:53 +0200
commit8e88e52ed06cd2f2197b5b08e3154c6be4a6d8ce (patch)
tree8b5545ac7d91aaf1c494c96ce81c0bdf5cbe164c
parent44a02d2532c4e6dabb8f2a074d52d5e99ff533be (diff)
downloadcurl-8e88e52ed06cd2f2197b5b08e3154c6be4a6d8ce.tar.gz
libssh2: setting atime or mtime >32bit on 4-bytes-long systems
Since the libssh2 API uses 'long' to store the timestamp, it cannot transfer >32bit times on Windows and 32bit architecture builds. Avoid nasty surprises by instead not setting such time. Spotted by Coverity Closes #9325
-rw-r--r--lib/vssh/libssh2.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
index 2026a88e5..9fd71b4f7 100644
--- a/lib/vssh/libssh2.c
+++ b/lib/vssh/libssh2.c
@@ -1766,8 +1766,15 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- sshp->quote_attrs.atime = (unsigned long)date;
- sshp->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+#if SIZEOF_TIME_T > SIZEOF_LONG
+ if(date > 0xffffffff)
+ ;
+ else
+#endif
+ {
+ sshp->quote_attrs.atime = (unsigned long)date;
+ sshp->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+ }
}
else if(strncasecompare(cmd, "mtime", 5)) {
time_t date = Curl_getdate_capped(sshc->quote_path1);
@@ -1780,8 +1787,15 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- sshp->quote_attrs.mtime = (unsigned long)date;
- sshp->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+#if SIZEOF_TIME_T > SIZEOF_LONG
+ if(date > 0xffffffff)
+ ;
+ else
+#endif
+ {
+ sshp->quote_attrs.mtime = (unsigned long)date;
+ sshp->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+ }
}
/* Now send the completed structure... */