--- src/ftp.c +++ src/ftp.c @@ -1196,7 +1196,7 @@ len = 0; err = getftp (u, &len, restval, con); - if (con->csock != -1) + if (con->csock == -1) con->st &= ~DONE_CWD; else con->st |= DONE_CWD; @@ -1220,6 +1220,8 @@ con->target = url_file_name (u); locf = con->target; } + /* len hasn't been touched by getftp */ + len = restval; continue; case FTPRETRINT: /* If the control connection was closed, the retrieval