mirror of
https://github.com/moparisthebest/curl
synced 2024-11-13 13:05:03 -05:00
SSH: avoid PATH_MAX with alloc
We cannot assume that PATH_MAX will be enough for the remote path name so allocating room for it is the only sensible approach.
This commit is contained in:
parent
569202c9a4
commit
45cea71968
10
lib/ssh.c
10
lib/ssh.c
@ -1046,10 +1046,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
*/
|
*/
|
||||||
if(curl_strequal("pwd", sshc->quote_item->data)) {
|
if(curl_strequal("pwd", sshc->quote_item->data)) {
|
||||||
/* output debug output if that is requested */
|
/* output debug output if that is requested */
|
||||||
char tmp[PATH_MAX+1];
|
char *tmp = aprintf("257 \"%s\" is current directory.\n",
|
||||||
|
|
||||||
snprintf(tmp, PATH_MAX, "257 \"%s\" is current directory.\n",
|
|
||||||
sftp_scp->path);
|
sftp_scp->path);
|
||||||
|
if(!tmp) {
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
|
state(conn, SSH_SFTP_CLOSE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(data->set.verbose) {
|
if(data->set.verbose) {
|
||||||
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4, conn);
|
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4, conn);
|
||||||
Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn);
|
Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn);
|
||||||
@ -1058,6 +1061,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
current directory can be read very similar to how it is read when
|
current directory can be read very similar to how it is read when
|
||||||
using ordinary FTP. */
|
using ordinary FTP. */
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_HEADER, tmp, strlen(tmp));
|
result = Curl_client_write(conn, CLIENTWRITE_HEADER, tmp, strlen(tmp));
|
||||||
|
free(tmp);
|
||||||
state(conn, SSH_SFTP_NEXT_QUOTE);
|
state(conn, SSH_SFTP_NEXT_QUOTE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user