cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1754793 ] No graceful failure from PASV command

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Mon, 16 Jul 2007 06:59:10 -0700

Bugs item #1754793, was opened at 2007-07-16 13:59
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1754793&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: ftp
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Daniel Cater (djc0)
Assigned to: Daniel Stenberg (bagder)
Summary: No graceful failure from PASV command

Initial Comment:
When trying to connect passively to a server which only supports active connections, libcurl returns CURLE_FTP_WEIRD_PASV_REPLY and closes the connection.

There should be a way to fallback to an active connection.

When EPSV fails, libcurl gracefully falls back to PASV.

My example is using an embedded FTP server on a piece of hardware. This is how it goes:

* About to connect() to 192.168.0.2 port 21 (#0)
* Trying 192.168.0.2... * connected
* Connected to 192.168.0.2 (192.168.0.2) port 21 (#0
< 220 FTP Server Ready...
> USER user
< 331 Password required for user user.
> PASS pass
< 230 User logged in.
> PWD
< 257 "/root"
* Entry path is '/root'
> EPSV
* Connect data stream passively
< 500 command not recognised.
* disabling EPSV usage
> PASV
< 502 Command not implemented.
* Bad PASV/EPSV response: 502
* Connection #0 to host 192.168.0.2 left intact
* FTP: unknown PASV reply
> QUIT
< 221 Closing connection ... goodbye.
* Closing connection #0

You can see that the EPSV failure is handled OK, but the PASV failure means the end of the connection.

RFC 959 lists the following possible responses to PASV:

PASV
                  227
                  500, 501, 502, 421, 530

I think that "502 Command not implemented." should not cause CURLE_FTP_WEIRD_PASV_REPLY. It is not "weird", merely stating that the server does not support passive connections.

This can be avoided by setting CURLOPT_FTPPORT to "-" but this is not ideal. If I don't know whether the server supports PASV or not, I would prefer it to try PASV first, then fall-back to active (PORT) like happens for EPSV.

I tried to patch the code at ftp.c:1718 but I couldn't solve it. I will try again later.

"CURLE_FTP_WEIRD_PASV_REPLY (13)

libcurl failed to get a sensible result back from the server as a response to either a PASV or a EPSV command. The server is flawed. "

Is an active-only server really "flawed"? Are all servers required to support PASV?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1754793&group_id=976
Received on 2007-07-16

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET