mirror of
https://github.com/curl/curl.git
synced 2025-09-30 07:56:57 +03:00
Added const to some pointer variables
This commit is contained in:
parent
79fc481a2b
commit
95456b8e78
|
@ -138,6 +138,12 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unescapes the given URL escaped string of given length. Returns a
|
||||||
|
* pointer to a malloced string with length given in *olen.
|
||||||
|
* If length == 0, the length is assumed to be strlen(string).
|
||||||
|
* If olen == NULL, no output length is stored.
|
||||||
|
*/
|
||||||
char *curl_easy_unescape(CURL *handle, const char *string, int length,
|
char *curl_easy_unescape(CURL *handle, const char *string, int length,
|
||||||
int *olen)
|
int *olen)
|
||||||
{
|
{
|
||||||
|
|
37
lib/ftp.c
37
lib/ftp.c
|
@ -3150,7 +3150,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
bool was_ctl_valid = ftpc->ctl_valid;
|
bool was_ctl_valid = ftpc->ctl_valid;
|
||||||
char *path;
|
char *path;
|
||||||
char *path_to_use = data->state.path;
|
const char *path_to_use = data->state.path;
|
||||||
|
|
||||||
if(!ftp)
|
if(!ftp)
|
||||||
/* When the easy handle is removed from the multi while libcurl is still
|
/* When the easy handle is removed from the multi while libcurl is still
|
||||||
|
@ -3860,10 +3860,10 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
/* the ftp struct is already inited in ftp_connect() */
|
/* the ftp struct is already inited in ftp_connect() */
|
||||||
struct FTP *ftp = data->state.proto.ftp;
|
struct FTP *ftp = data->state.proto.ftp;
|
||||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||||
size_t dlen;
|
const char *slash_pos; /* position of the first '/' char in curpos */
|
||||||
char *slash_pos; /* position of the first '/' char in curpos */
|
const char *path_to_use = data->state.path;
|
||||||
char *path_to_use = data->state.path;
|
const char *cur_pos;
|
||||||
char *cur_pos;
|
const char *filename = NULL;
|
||||||
|
|
||||||
cur_pos = path_to_use; /* current position in path. point at the begin
|
cur_pos = path_to_use; /* current position in path. point at the begin
|
||||||
of next path component */
|
of next path component */
|
||||||
|
@ -3885,13 +3885,11 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
if(data->state.path &&
|
if(data->state.path &&
|
||||||
data->state.path[0] &&
|
data->state.path[0] &&
|
||||||
(data->state.path[strlen(data->state.path) - 1] != '/') )
|
(data->state.path[strlen(data->state.path) - 1] != '/') )
|
||||||
ftpc->file = data->state.path; /* this is a full file path */
|
filename = data->state.path; /* this is a full file path */
|
||||||
else
|
|
||||||
ftpc->file = NULL;
|
|
||||||
/*
|
/*
|
||||||
ftpc->file is not used anywhere other than for operations on a file.
|
ftpc->file is not used anywhere other than for operations on a file.
|
||||||
In other words, never for directory operations.
|
In other words, never for directory operations.
|
||||||
So we can safely set it to NULL here and use it as a
|
So we can safely leave filename as NULL here and use it as a
|
||||||
argument in dir/file decisions.
|
argument in dir/file decisions.
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
@ -3901,7 +3899,6 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
if(!path_to_use[0]) {
|
if(!path_to_use[0]) {
|
||||||
/* no dir, no file */
|
/* no dir, no file */
|
||||||
ftpc->dirdepth = 0;
|
ftpc->dirdepth = 0;
|
||||||
ftpc->file = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
slash_pos=strrchr(cur_pos, '/');
|
slash_pos=strrchr(cur_pos, '/');
|
||||||
|
@ -3918,10 +3915,10 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
ftpc->dirdepth = 1; /* we consider it to be a single dir */
|
ftpc->dirdepth = 1; /* we consider it to be a single dir */
|
||||||
ftpc->file = slash_pos ? slash_pos+1 : cur_pos; /* rest is file name */
|
filename = slash_pos ? slash_pos+1 : cur_pos; /* rest is file name */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ftpc->file = cur_pos; /* this is a file name only */
|
filename = cur_pos; /* this is a file name only */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* allow pretty much anything */
|
default: /* allow pretty much anything */
|
||||||
|
@ -3983,11 +3980,12 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ftpc->file = cur_pos; /* the rest is the file name */
|
filename = cur_pos; /* the rest is the file name */
|
||||||
}
|
break;
|
||||||
|
} /* switch */
|
||||||
|
|
||||||
if(ftpc->file && *ftpc->file) {
|
if(filename && *filename) {
|
||||||
ftpc->file = curl_easy_unescape(conn->data, ftpc->file, 0, NULL);
|
ftpc->file = curl_easy_unescape(conn->data, filename, 0, NULL);
|
||||||
if(NULL == ftpc->file) {
|
if(NULL == ftpc->file) {
|
||||||
freedirs(ftpc);
|
freedirs(ftpc);
|
||||||
failf(data, "no memory");
|
failf(data, "no memory");
|
||||||
|
@ -4013,14 +4011,15 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
if(ftpc->prevpath) {
|
if(ftpc->prevpath) {
|
||||||
/* prevpath is "raw" so we convert the input path before we compare the
|
/* prevpath is "raw" so we convert the input path before we compare the
|
||||||
strings */
|
strings */
|
||||||
char *path = curl_easy_unescape(conn->data, data->state.path, 0, NULL);
|
int dlen;
|
||||||
|
char *path = curl_easy_unescape(conn->data, data->state.path, 0, &dlen);
|
||||||
if(!path) {
|
if(!path) {
|
||||||
freedirs(ftpc);
|
freedirs(ftpc);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlen = strlen(path) - (ftpc->file?strlen(ftpc->file):0);
|
dlen -= ftpc->file?strlen(ftpc->file):0;
|
||||||
if((dlen == strlen(ftpc->prevpath)) &&
|
if((dlen == (int)strlen(ftpc->prevpath)) &&
|
||||||
curl_strnequal(path, ftpc->prevpath, dlen)) {
|
curl_strnequal(path, ftpc->prevpath, dlen)) {
|
||||||
infof(data, "Request has same path as previous transfer\n");
|
infof(data, "Request has same path as previous transfer\n");
|
||||||
ftpc->cwddone = TRUE;
|
ftpc->cwddone = TRUE;
|
||||||
|
|
|
@ -2046,11 +2046,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||||
char *buf = data->state.buffer; /* this is a short cut to the buffer */
|
char *buf = data->state.buffer; /* this is a short cut to the buffer */
|
||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
struct HTTP *http;
|
struct HTTP *http;
|
||||||
char *ppath = data->state.path;
|
const char *ppath = data->state.path;
|
||||||
char ftp_typecode[sizeof(";type=?")] = "";
|
char ftp_typecode[sizeof(";type=?")] = "";
|
||||||
char *host = conn->host.name;
|
const char *host = conn->host.name;
|
||||||
const char *te = ""; /* transfer-encoding */
|
const char *te = ""; /* transfer-encoding */
|
||||||
char *ptr;
|
const char *ptr;
|
||||||
const char *request;
|
const char *request;
|
||||||
Curl_HttpReq httpreq = data->set.httpreq;
|
Curl_HttpReq httpreq = data->set.httpreq;
|
||||||
char *addcookies = NULL;
|
char *addcookies = NULL;
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
<keywords>
|
<keywords>
|
||||||
FTP
|
FTP
|
||||||
FAILURE
|
FAILURE
|
||||||
compressed
|
|
||||||
</keywords>
|
</keywords>
|
||||||
</info>
|
</info>
|
||||||
|
|
||||||
# Client-side
|
# Client-side
|
||||||
<client>
|
<client>
|
||||||
<server>
|
<server>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user