From 0c1b52637f23c64b1dae919fc72e387ec220b1e1 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 21 Jan 2008 23:12:41 +0200 Subject: [PATCH] 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 (887d650efe447ce534cc36f92f9c07e25414e8f8), on 2007-05-01. --- NEWS | 2 +- src/network/socket.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index eca1a50f..f4cc3307 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/src/network/socket.c b/src/network/socket.c index c69096d6..32c16337 100644 --- a/src/network/socket.c +++ b/src/network/socket.c @@ -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;