From: Daniel Stenberg Date: Tue, 15 Oct 2024 22:17:24 +0000 (+0200) Subject: libssh2: use the filename buffer when getting the homedir X-Git-Tag: curl-8_11_0~141 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=facf59c30e9a6a10c4f2acb26b62f944919deffe;p=thirdparty%2Fcurl.git libssh2: use the filename buffer when getting the homedir Avoids having to use a big stack buffer for this. Closes #15285 --- diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 505adc4456..e0b9487bef 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -2046,21 +2046,18 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block) break; case SSH_SFTP_REALPATH: - { - char tempHome[CURL_PATH_MAX]; - /* * Get the "home" directory */ rc = sftp_libssh2_realpath(sshc->sftp_session, ".", - tempHome, CURL_PATH_MAX-1); + sshp->readdir_filename, CURL_PATH_MAX); if(rc == LIBSSH2_ERROR_EAGAIN) { break; } if(rc > 0) { /* It seems that this string is not always NULL terminated */ - tempHome[rc] = '\0'; - sshc->homedir = strdup(tempHome); + sshp->readdir_filename[rc] = '\0'; + sshc->homedir = strdup(sshp->readdir_filename); if(!sshc->homedir) { state(data, SSH_SFTP_CLOSE); sshc->actualcode = CURLE_OUT_OF_MEMORY; @@ -2083,7 +2080,7 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block) state(data, SSH_STOP); break; } - } + /* This is the last step in the SFTP connect phase. Do note that while we get the homedir here, we get the "workingpath" in the DO action since the homedir will remain the same between request but the