Skip to content

FTP ASCII download fails due to erroneous SIZE response #6564

Closed
@awesomenode

Description

@awesomenode

Hi!

Found some FTP servers which refuse to give SIZE response in ASCII mode.
One such is proftpd, their reasoning is here: http://www.proftpd.org/docs/howto/ASCII.html

Now with the change in 7ea2e1d
it is not possible to download in ascii mode from these servers as the download fails on the 550 response to the SIZE command.

Prior to that the download continues with "unkown" size.

Could you please fix this, or eg add an option so we allow ASCII mode SIZE to fail?

I did this

FTP ASCII mode download from proftpd fails.

I expected the following

Download succeeds.

curl/libcurl version

7.74

operating system

Linux.

Thanks!

Activity

bagder

bagder commented on Feb 4, 2021

@bagder
Member

Does the server really return a 550 in that situation? To me that seems... wrong.

awesomenode

awesomenode commented on Feb 4, 2021

@awesomenode
Author
$ curl -V
curl 7.71.0 (x86_64-pc-linux-gnu) libcurl/7.71.0 OpenSSL/1.0.2u zlib/1.2.7 libssh2/1.8.0
Release-Date: 2020-06-24
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets
$ curl -B ftp://ip/welcome.msg -o /dev/null -v
*   Trying ip:21...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to ip (ip) port 21 (#0)
  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0< 220 ProFTPD 1.3.5b Server (Debian) [ip]
> USER anonymous
  0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0< 331 Anonymous login ok, send your complete email address as your password
> PASS ftp@example.com
< 230-Welcome, archive user anonymous@ip !
< 230-
< 230-The local time is: Fri Feb 04 12:28:16 2011
< 230-
< 230-This is an experimental FTP server.  If you have any unusual problems,
< 230-please report them via e-mail to <root@>.
< 230-
< 230 Anonymous access granted, restrictions apply
> PWD
< 257 "/" is the current directory
* Entry path is '/'
* Request has same path as previous transfer
> EPSV
* Connect data stream passively
* ftp_perform ends with SECONDARY: 0
< 229 Entering Extended Passive Mode (|||2128|)
*   Trying ip:2128...
* Connecting to ip (ip) port 2128
* Connected to ip (ip) port 21 (#0)
> TYPE A
< 200 Type set to A
> SIZE welcome.msg
< 550 SIZE not allowed in ASCII mode
> RETR welcome.msg
< 150 Opening ASCII mode data connection for welcome.msg (170 bytes)
* Maxdownload = -1
* Getting file with size: -1
{ [177 bytes data]
* Remembering we are in dir ""
< 226 Transfer complete
100   177    0   177    0     0     16      0 --:--:--  0:00:10 --:--:--    40
* Connection #0 to host ip left intact

Yep it seems buggy to me also. But these are already out there. :(

self-assigned this
on Feb 4, 2021
added a commit that references this issue on Feb 4, 2021
6487a86
linked a pull request that will close this issueFTP: avoid SIZE for TYPE A transfers #6565on Feb 4, 2021
bagder

bagder commented on Feb 4, 2021

@bagder
Member

I went with skipping SIZE completely for TYPE A transfers. curl can't use the returned size anyway since servers tend to not send back the actual (converted) size for it so avoiding it seems like the better choice!

awesomenode

awesomenode commented on Feb 4, 2021

@awesomenode
Author

Excellent, thank you Daniel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @bagder@awesomenode

    Issue actions

      FTP ASCII download fails due to erroneous SIZE response · Issue #6564 · curl/curl