1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

get_pasv_socket: Use AF_INET6 when appropriate.

When get_pasv6_socket was merged into get_pasv_socket on 2005-04-15,
the AF_INET6 of get_pasv6_socket was lost and the merged function
always returned AF_INET sockets.  This then made getsockname fill
only part of the struct sockaddr_in6, and ELinks sent to the server
an EPRT command that had half the bits missing from the IPv6 address.
At least ftp.funet.fi then rejected the command, helpfully saying
what the address should have been.

This commit fixes active FTP over IPv6.  Passive FTP was already fixed
in 0.11.3.GIT (887d650efe), on 2007-05-01.
This commit is contained in:
Kalle Olavi Niemitalo 2008-01-21 23:12:41 +02:00 committed by Kalle Olavi Niemitalo
parent 789eacc0d9
commit 0c1b52637f
2 changed files with 5 additions and 2 deletions

2
NEWS
View File

@ -301,7 +301,7 @@ To be released as 0.11.4.
* bug 691: don't look up bogus IPv4 addresses based on characters of a
hostname
* bug 712: GnuTLS works on https://www-s.uiuc.edu/[]
* fix passive FTP over IPv6 when connect() fails with EINPROGRESS
* fix active and passive FTP over IPv6
* minor bug 951 in user SMJS: garbage-collect SMJS objects on 'File ->
Flush all caches' to work around their holding cache entries busy
* minor bug 396: never show empty filename in the what-to-do dialog

View File

@ -282,6 +282,7 @@ get_pasv_socket(struct socket *ctrl_socket, struct sockaddr_storage *addr)
struct sockaddr *pasv_addr = (struct sockaddr *) addr;
size_t addrlen;
int sock = -1;
int syspf; /* Protocol Family given to system, not EL_PF_... */
socklen_t len;
#ifdef CONFIG_IPV6
struct sockaddr_in6 bind_addr6;
@ -289,11 +290,13 @@ get_pasv_socket(struct socket *ctrl_socket, struct sockaddr_storage *addr)
if (ctrl_socket->protocol_family == EL_PF_INET6) {
bind_addr = (struct sockaddr *) &bind_addr6;
addrlen = sizeof(bind_addr6);
syspf = PF_INET6;
} else
#endif
{
bind_addr = (struct sockaddr *) &bind_addr4;
addrlen = sizeof(bind_addr4);
syspf = PF_INET;
}
memset(pasv_addr, 0, sizeof(addrlen));
@ -310,7 +313,7 @@ sock_error:
/* Get a passive socket */
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
sock = socket(syspf, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0)
goto sock_error;