1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-04 16:45:06 -05:00

ftp: never set data->set.ftp_append outside setopt

Since the set value then risks getting used like that when the easy
handle is reused by the application.

Also: renamed the struct field from 'ftp_append' to 'remote_append'
since it is also used for SSH protocols.

Closes #6579
This commit is contained in:
Daniel Stenberg 2021-02-08 16:21:31 +01:00
parent d836d362ec
commit 0c51036eb6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
6 changed files with 8 additions and 8 deletions

View File

@ -1578,6 +1578,7 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data,
struct connectdata *conn = data->conn;
struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
bool append = data->set.remote_append;
if((data->state.resume_from && !sizechecked) ||
((data->state.resume_from > 0) && sizechecked)) {
@ -1604,7 +1605,7 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data,
}
/* enable append */
data->set.ftp_append = TRUE;
append = TRUE;
/* Let's read off the proper amount of bytes from the input. */
if(conn->seek_func) {
@ -1661,8 +1662,7 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data,
/* we've passed, proceed as normal */
} /* resume_from */
result = Curl_pp_sendf(data, &ftpc->pp,
data->set.ftp_append?"APPE %s":"STOR %s",
result = Curl_pp_sendf(data, &ftpc->pp, append?"APPE %s":"STOR %s",
ftpc->file);
if(!result)
state(data, FTP_STOR);

View File

@ -1165,7 +1165,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* We want to upload and append to an existing file. Used for FTP and
* SFTP.
*/
data->set.ftp_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
data->set.remote_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
break;
#ifndef CURL_DISABLE_FTP

View File

@ -1792,7 +1792,7 @@ struct UserDefined {
BIT(get_filetime); /* get the time and get of the remote file */
BIT(tunnel_thru_httpproxy); /* use CONNECT through a HTTP proxy */
BIT(prefer_ascii); /* ASCII rather than binary */
BIT(ftp_append); /* append, not overwrite, on upload */
BIT(remote_append); /* append, not overwrite, on upload */
BIT(ftp_list_only); /* switch FTP command for listing directories */
#ifndef CURL_DISABLE_FTP
BIT(ftp_use_port); /* use the FTP PORT command */

View File

@ -1224,7 +1224,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
}
}
if(data->set.ftp_append)
if(data->set.remote_append)
/* Try to open for append, but create if nonexisting */
flags = O_WRONLY|O_CREAT|O_APPEND;
else if(data->state.resume_from > 0)

View File

@ -1880,7 +1880,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
}
}
if(data->set.ftp_append)
if(data->set.remote_append)
/* Try to open for append, but create if nonexisting */
flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_APPEND;
else if(data->state.resume_from > 0)

View File

@ -585,7 +585,7 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block)
}
}
if(data->set.ftp_append)
if(data->set.remote_append)
/* Try to open for append, but create if nonexisting */
flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_APPEND;
else if(data->state.resume_from > 0)