From: Daniel Stenberg Date: Tue, 16 Aug 2022 14:22:51 +0000 (+0200) Subject: libssh: setting atime or mtime > 32bit is now just skipped X-Git-Tag: curl-7_85_0~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=44a02d2532c4e6dabb8f2a074d52d5e99ff533be;p=thirdparty%2Fcurl.git libssh: setting atime or mtime > 32bit is now just skipped The libssh API used caps the time to an unsigned 32bit variable. Avoid nasty surprises by instead not setting such time. Spotted by Coverity. Closes #9324 --- diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 5aa99e618b..c2f71d0305 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2922,8 +2922,15 @@ static void sftp_quote_stat(struct Curl_easy *data) sshc->actualcode = CURLE_QUOTE_ERROR; return; } - sshc->quote_attrs->atime = (uint32_t)date; - sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME; +#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(strncasecompare(cmd, "mtime", 5)) { time_t date = Curl_getdate_capped(sshc->quote_path1); @@ -2936,8 +2943,15 @@ static void sftp_quote_stat(struct Curl_easy *data) sshc->actualcode = CURLE_QUOTE_ERROR; return; } - sshc->quote_attrs->mtime = (uint32_t)date; - sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME; +#if SIZEOF_TIME_T > 4 + if(date > 0xffffffff) + ; /* avoid setting a capped time */ + else +#endif + { + sshc->quote_attrs->mtime = (uint32_t)date; + sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME; + } } /* Now send the completed structure... */