Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTP Bug: wrong dir listing because libcurl remembers wrong CWD #1782

Closed
PeterLamare2 opened this issue Aug 14, 2017 · 1 comment
Closed

FTP Bug: wrong dir listing because libcurl remembers wrong CWD #1782

PeterLamare2 opened this issue Aug 14, 2017 · 1 comment
Labels

Comments

@PeterLamare2
Copy link

I think this is caused by the changes in:
#1718

Steps to reproduce:
When the first easy handle uses CURLFTPMETHOD_MULTICWD and accesses some path /subfolder, libcurl stores this under ftpc->prevpath.

The easy handle is then reused, but this time using CURLFTPMETHOD_NOCWD, also passing /subfolder as CURLOPT_URL.
Now in ftp.c:: ftp_parse_url_path, there is still this code which does not consider CURLFTPMETHOD

  ftpc->cwddone = FALSE; /* default to not done */

  if(ftpc->prevpath) {
    /* prevpath is "raw" so we convert the input path before we compare the
       strings */
    size_t dlen;
    char *path;
    CURLcode result =
      Curl_urldecode(conn->data, data->state.path, 0, &path, &dlen, FALSE);
    if(result) {
      freedirs(ftpc);
      return result;
    }

    dlen -= ftpc->file?strlen(ftpc->file):0;
    if((dlen == strlen(ftpc->prevpath)) &&
       !strncmp(path, ftpc->prevpath, dlen)) {
      infof(data, "Request has same path as previous transfer\n");
      ftpc->cwddone = TRUE;
    }
    free(path);
  }

Consequence: ftpc->cwddone = TRUE; will be set, which is incorrect for CURLFTPMETHOD_NOCWD, which is supposed to operate on the ftp entry path.

As a result, the CURLFTPMETHOD_NOCWD + "MLSD subfolder" will not find any results, because the working dir is alreay at /subfolder! (consider CURLOPT_CUSTOMREQUEST MLSD)

-Lama

@bagder
Copy link
Member

bagder commented Aug 15, 2017

@PeterLamare2 any chance you can try the fix in #1787 just to be sure it fixes the problem for you the way I intended it to?

@bagder bagder closed this as completed in c95eff4 Aug 17, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants