mirror of
https://github.com/curl/curl.git
synced 2025-09-21 19:42:42 +03:00
Work around an out of memory situation in Curl_ftp_done instead of
returning an error code, to allow connections to be torn down cleanly since this function can be called AFTER an OOM situation has already been reached.
This commit is contained in:
parent
42c0ac2008
commit
70cce4cddd
34
lib/ftp.c
34
lib/ftp.c
|
@ -2996,8 +2996,6 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature
|
||||||
int ftpcode;
|
int ftpcode;
|
||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
bool was_ctl_valid = ftpc->ctl_valid;
|
bool was_ctl_valid = ftpc->ctl_valid;
|
||||||
size_t flen;
|
|
||||||
size_t dlen;
|
|
||||||
char *path;
|
char *path;
|
||||||
char *path_to_use = data->reqdata.path;
|
char *path_to_use = data->reqdata.path;
|
||||||
struct Curl_transfer_keeper *k = &data->reqdata.keep;
|
struct Curl_transfer_keeper *k = &data->reqdata.keep;
|
||||||
|
@ -3043,21 +3041,25 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature
|
||||||
|
|
||||||
/* get the "raw" path */
|
/* get the "raw" path */
|
||||||
path = curl_easy_unescape(data, path_to_use, 0, NULL);
|
path = curl_easy_unescape(data, path_to_use, 0, NULL);
|
||||||
if(!path)
|
if(!path) {
|
||||||
return CURLE_OUT_OF_MEMORY;
|
/* out of memory, but we can limp along anyway (and should try to
|
||||||
|
* since we're in the out of memory cleanup path) */
|
||||||
flen = ftp->file?strlen(ftp->file):0; /* file is "raw" already */
|
|
||||||
dlen = strlen(path)-flen;
|
|
||||||
if(dlen && !ftpc->cwdfail) {
|
|
||||||
ftpc->prevpath = path;
|
|
||||||
if(flen)
|
|
||||||
/* if 'path' is not the whole string */
|
|
||||||
ftpc->prevpath[dlen]=0; /* terminate */
|
|
||||||
infof(data, "Remembering we are in dir %s\n", ftpc->prevpath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ftpc->prevpath = NULL; /* no path */
|
ftpc->prevpath = NULL; /* no path */
|
||||||
free(path);
|
|
||||||
|
} else {
|
||||||
|
size_t flen = ftp->file?strlen(ftp->file):0; /* file is "raw" already */
|
||||||
|
size_t dlen = strlen(path)-flen;
|
||||||
|
if(dlen && !ftpc->cwdfail) {
|
||||||
|
ftpc->prevpath = path;
|
||||||
|
if(flen)
|
||||||
|
/* if 'path' is not the whole string */
|
||||||
|
ftpc->prevpath[dlen]=0; /* terminate */
|
||||||
|
infof(data, "Remembering we are in dir %s\n", ftpc->prevpath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ftpc->prevpath = NULL; /* no path */
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* free the dir tree and file parts */
|
/* free the dir tree and file parts */
|
||||||
freedirs(conn);
|
freedirs(conn);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user