summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-02-08 16:21:31 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-02-08 16:21:31 +0100
commit875966fc28e9bdc5e976e626fade8b0cb6e66573 (patch)
tree9df1e3918dea441aee44cecf53a79b533a1f80f7
parentc30bf22f1c1b2d5043517845204d53d6752db0fe (diff)
downloadcurl-bagder/ftp-append.tar.gz
ftp: never set data->set.ftp_append outside setoptbagder/ftp-append
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.
-rw-r--r--lib/ftp.c6
-rw-r--r--lib/setopt.c2
-rw-r--r--lib/urldata.h2
-rw-r--r--lib/vssh/libssh.c2
-rw-r--r--lib/vssh/libssh2.c2
-rw-r--r--lib/vssh/wolfssh.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 8de959c40..c888b7858 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -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);
diff --git a/lib/setopt.c b/lib/setopt.c
index d4a081681..4e0cbc3f8 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -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
diff --git a/lib/urldata.h b/lib/urldata.h
index 09a78d922..7abac1e8f 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1796,7 +1796,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 */
diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
index 08896ab5b..dfdef12af 100644
--- a/lib/vssh/libssh.c
+++ b/lib/vssh/libssh.c
@@ -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)
diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
index 3130dcc74..dbbeb2322 100644
--- a/lib/vssh/libssh2.c
+++ b/lib/vssh/libssh2.c
@@ -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)
diff --git a/lib/vssh/wolfssh.c b/lib/vssh/wolfssh.c
index 6020180a5..c0de33984 100644
--- a/lib/vssh/wolfssh.c
+++ b/lib/vssh/wolfssh.c
@@ -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)