cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: relative path with ftp using curl

From: François Pons <fpons_at_mandrakesoft.com>
Date: 24 Jul 2003 18:38:35 +0200

fpons_at_mandrakesoft.com (François Pons) writes:

> fpons_at_mandrakesoft.com (François Pons) writes:
>
> > It seems to be unable to fetch an url (ftp://user:pass//dir) where /dir is
> > absolute directory and not relative directory from $HOME of user.
> >
> > Is it a normal behaviour for security purpose or does there exists an option to
> > enable this ?
>
> The problem seems located in ftp.c:2150 (7.10.6-pre4) where any / are removed
> from path, I wonder if this is intentional but it seems not according to
> comments here.

Here is a patch to allow absolute directory to be fetched but only at the cost
of at least 3 slashes (like ftp://user:pass///dir) in order not to fail test
106.

--- curl-7.10.6-pre4/lib/ftp.c.fpons 2003-07-24 18:09:57.000000000 +0200
+++ curl-7.10.6-pre4/lib/ftp.c 2003-07-24 18:19:02.000000000 +0200
@@ -2134,12 +2134,15 @@

   /* parse the URL path into separate path components */
   while((slash_pos=strchr(cur_pos, '/'))) {
+ /* 1 or 0 to indicate absolute directory */
+ int absolute_dir = cur_pos - conn->ppath > 1 && path_part == 0;
     /* seek out the next path component */
     if (slash_pos-cur_pos) {
       /* we skip empty path components, like "x//y" since the FTP command CWD
          requires a parameter and a non-existant parameter a) doesn't work on
          many servers and b) has no effect on the others. */
- ftp->dirs[path_part] = curl_unescape(cur_pos,slash_pos-cur_pos);
+ ftp->dirs[path_part] = curl_unescape(cur_pos-absolute_dir,
+ slash_pos-cur_pos+absolute_dir);

       if (!ftp->dirs[path_part]) { /* run out of memory ... */
         failf(data, "no memory");

François.

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-07-24