curl-library
Re: ftp->prevpath bug?
Date: Thu, 16 Dec 2004 23:04:36 +0100
> RCS file: /cvsroot/curl/curl/lib/ftp.c,v
> retrieving revision 1.285
> diff -u -r1.285 ftp.c
And a diff against latest ftp.c:
===================================================================
RCS file: /cvsroot/curl/curl/lib/ftp.c,v
retrieving revision 1.286
diff -u -r1.286 ftp.c
--- ftp.c 16 Dec 2004 18:18:23 -0000 1.286
+++ ftp.c 16 Dec 2004 21:33:16 -0000
@@ -765,24 +765,36 @@
bool was_ctl_valid = ftp->ctl_valid;
size_t flen;
size_t dlen;
+ char *path;
/* now store a copy of the directory we are in */
if(ftp->prevpath)
free(ftp->prevpath);
- flen = ftp->file?strlen(ftp->file):0;
- dlen = conn->path?strlen(conn->path)-flen:0;
+ if (conn->path) {
+ path = curl_unescape(conn->path, 0);
+ if(!path)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ else
+ path = NULL;
+
+ flen = ftp->file ? strlen(ftp->file) : 0;
+ dlen = path ? strlen(path)-flen : 0;
if(dlen) {
ftp->prevpath = malloc(dlen + 1);
if(!ftp->prevpath)
return CURLE_OUT_OF_MEMORY;
- memcpy(ftp->prevpath, conn->path, dlen);
+ memcpy(ftp->prevpath, path, dlen);
ftp->prevpath[dlen]=0; /* terminate */
infof(data, "Remembering we are in dir %s\n", ftp->prevpath);
}
else
ftp->prevpath = NULL; /* no path */
+ if (path)
+ free(path);
+
/* free the dir tree and file parts */
freedirs(ftp);
--gv
Received on 2004-12-16