mirror of
https://github.com/curl/curl.git
synced 2026-07-26 08:57:16 +03:00
ftp/sftp: strdup data info memory
Fix the broken implementation to have `data->state` carry pointers into connectdata members. Always dup the memory and free when easy handle closes. Closes #16733
This commit is contained in:
parent
d12129dda5
commit
ebce3f0c02
4 changed files with 18 additions and 15 deletions
|
|
@ -944,7 +944,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
|
||||
break;
|
||||
}
|
||||
data->state.most_recent_ftp_entrypath = sshc->homedir;
|
||||
free(data->state.most_recent_ftp_entrypath);
|
||||
data->state.most_recent_ftp_entrypath = strdup(sshc->homedir);
|
||||
if(!data->state.most_recent_ftp_entrypath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* 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
|
||||
|
|
@ -1763,7 +1766,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
SSH_STRING_FREE_CHAR(sshc->homedir);
|
||||
data->state.most_recent_ftp_entrypath = NULL;
|
||||
|
||||
state(data, SSH_SESSION_DISCONNECT);
|
||||
break;
|
||||
|
|
@ -1939,7 +1941,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
SSH_STRING_FREE_CHAR(sshc->homedir);
|
||||
data->state.most_recent_ftp_entrypath = NULL;
|
||||
|
||||
state(data, SSH_SESSION_FREE);
|
||||
FALLTHROUGH();
|
||||
|
|
|
|||
|
|
@ -2008,7 +2008,10 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
|
|||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
data->state.most_recent_ftp_entrypath = sshc->homedir;
|
||||
free(data->state.most_recent_ftp_entrypath);
|
||||
data->state.most_recent_ftp_entrypath = strdup(sshc->homedir);
|
||||
if(!data->state.most_recent_ftp_entrypath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
/* Return the error type */
|
||||
|
|
@ -2591,7 +2594,6 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
Curl_safefree(sshc->homedir);
|
||||
data->state.most_recent_ftp_entrypath = NULL;
|
||||
|
||||
state(data, SSH_SESSION_DISCONNECT);
|
||||
break;
|
||||
|
|
@ -2857,7 +2859,6 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
Curl_safefree(sshc->homedir);
|
||||
data->state.most_recent_ftp_entrypath = NULL;
|
||||
|
||||
state(data, SSH_SESSION_FREE);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue