diff options
author | Damien Miller <djm@mindrot.org> | 2003-01-07 10:51:23 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2003-01-07 10:51:23 +1100 |
commit | 5e4471e45a9ba9a4ecafa91e15142feaa682bf02 (patch) | |
tree | e72e83e50899fb10634e6ab7992875d5310fa6b5 /canohost.c | |
parent | dfedbf8e5a1f6719a9e91f79900d8cc0d055c453 (diff) |
- (djm) Bug #401: Work around Linux breakage with IPv6 mapped addresses.
Based on fix from yoshfuji@linux-ipv6.org
Diffstat (limited to 'canohost.c')
-rw-r--r-- | canohost.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -59,11 +59,14 @@ get_remote_hostname(int socket, int verify_reverse_mapping) memset(&from, 0, sizeof(from)); from4->sin_family = AF_INET; + fromlen = sizeof(*from4); memcpy(&from4->sin_addr, &addr, sizeof(addr)); from4->sin_port = port; } } #endif + if (from.ss_family == AF_INET6) + fromlen = sizeof(struct sockaddr_in6); if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST) != 0) @@ -225,6 +228,11 @@ get_socket_address(int socket, int remote, int flags) < 0) return NULL; } + + /* Work around Linux IPv6 weirdness */ + if (addr.ss_family == AF_INET6) + addrlen = sizeof(struct sockaddr_in6); + /* Get the address in ascii. */ if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), NULL, 0, flags) != 0) { @@ -319,6 +327,11 @@ get_sock_port(int sock, int local) fatal_cleanup(); } } + + /* Work around Linux IPv6 weirdness */ + if (from.ss_family == AF_INET6) + fromlen = sizeof(struct sockaddr_in6); + /* Return port number. */ if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, strport, sizeof(strport), NI_NUMERICSERV) != 0) |