cURL cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] #1468 Cannot connect to FTP on link-local IPv6

From: Vojtech Kral <vkral_at_users.sf.net>
Date: Sun, 04 Jan 2015 14:45:46 +0000

More info and maybe a fix:

Here's a trace of what happens:
    
    $ curl -v -u user:password -l ftp://foobar:33333/
    * Hostname was NOT found in DNS cache
    * Trying fe80::XXXX:XXXX:XXXX:2c6f...
    * Connected to foobar (fe80::XXXX:XXXX:XXXX:2c6f) port 33333 (#0)
    < 220 Service ready for new user.
> USER user
    < 331 User name okay, need password for user.
> PASS password
    < 230 User logged in, proceed.
> PWD
    < 257 "/bar/baz" is current directory.
    * Entry path is '/bar/baz'
> EPSV
    * Connect data stream passively
    * ftp_perform ends with SECONDARY: 0
    < 229 Entering Passive Mode (|||45508|)
    * Hostname was NOT found in DNS cache
    * Trying fe80::XXXX:XXXX:XXXX:2c6f...
    * Immediate connect fail for fe80::XXXX:XXXX:XXXX:2c6f: Invalid argument
    * Failed EPSV attempt. Disabling EPSV
> PASV
    < 227 Entering Passive Mode (fe80::XXXX:XXXX:XXXX:2c6f%wlan0,223,245)
    * Couldn't interpret the 227-response
    * Closing connection 0
    curl: (14) Couldn't interpret the 227-response
    
So, apparently, an EPSV response is parsed, but the connection subsequently fails and so curl tries to switch to PASV wich then fails to parse because we're on IPv6 and PASV is not defined for IPv6. (Never mind the server's PASV response - that's non-standard.)

The reason the connection after EPSV fails is on line 1963 in ftp.c - the original IPv6 address is copied but the zoneID/scopeID is not copied anywhere and cannot be resolved.

How to fix this?
Copy the original host name instead of the ip address string. This is very easy - simply replace `conn->ip_addr_str` on the line I mentioned with `conn->host.name`. I've tested this and it works. The downside is the hostname has to resolved again - for some reason it was not cached when I tested this even though it's literally the same hostname as for the first connection. Also, I'm not sure this is the right way to fix the thing - is it okay to have the host name resolved again?

---
** [bugs:#1468] Cannot connect to FTP on link-local IPv6**
**Status:** open
**Created:** Sat Jan 03, 2015 10:27 PM UTC by Vojtech Kral
**Last Updated:** Sun Jan 04, 2015 01:53 PM UTC
**Owner:** nobody
    $ curl -u user:password -l ftp://name-that-resolves-to-link-local-ipv6/
    curl: (14) Couldn't interpret the 227-response
    
    Response wireshark log:
    0000   32 32 37 20 45 6e 74 65 72 69 6e 67 20 50 61 73  227 Entering Pas
    0010   73 69 76 65 20 4d 6f 64 65 20 28 66 65 38 30 3a  sive Mode (fe80:
    0020   3a __ __ __ __ 3a __ __ __ __ 3a __ __ __ __ 3a  :____:____:____:
    0030   32 63 36 66 25 77 6c 61 6e 30 2c 32 32 33 2c 31  2c6f%wlan0,223,1
    0040   36 31 29 0d 0a                                   61)..
    
    I censored a part of my server's IPv6
    My guess is the zone ID / scope ID is not parsed
    
    
    $ curl -V
    curl 7.39.0 (x86_64-unknown-linux-gnu) libcurl/7.39.0 OpenSSL/1.0.1j zlib/1.2.8 libidn/1.29 libssh2/1.4.3
    Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
    Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP
---
Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to https://sourceforge.net/p/curl/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/curl/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
Received on 2015-01-04

These mail archives are generated by hypermail.