- (djm) Bug #401: Work around Linux breakage with IPv6 mapped addresses.

Based on fix from yoshfuji@linux-ipv6.org
This commit is contained in:
Damien Miller 2003-01-07 10:51:23 +11:00
parent dfedbf8e5a
commit 5e4471e45a
2 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,7 @@
20030107
- (djm) Bug #401: Work around Linux breakage with IPv6 mapped addresses.
Based on fix from yoshfuji@linux-ipv6.org
20030103 20030103
- (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from - (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from
cjwatson@debian.org cjwatson@debian.org
@ -925,4 +929,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284; save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@ ok provos@
$Id: ChangeLog,v 1.2540 2003/01/03 03:52:53 djm Exp $ $Id: ChangeLog,v 1.2541 2003/01/06 23:51:23 djm Exp $

View File

@ -59,11 +59,14 @@ get_remote_hostname(int socket, int verify_reverse_mapping)
memset(&from, 0, sizeof(from)); memset(&from, 0, sizeof(from));
from4->sin_family = AF_INET; from4->sin_family = AF_INET;
fromlen = sizeof(*from4);
memcpy(&from4->sin_addr, &addr, sizeof(addr)); memcpy(&from4->sin_addr, &addr, sizeof(addr));
from4->sin_port = port; from4->sin_port = port;
} }
} }
#endif #endif
if (from.ss_family == AF_INET6)
fromlen = sizeof(struct sockaddr_in6);
if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop), if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop),
NULL, 0, NI_NUMERICHOST) != 0) NULL, 0, NI_NUMERICHOST) != 0)
@ -225,6 +228,11 @@ get_socket_address(int socket, int remote, int flags)
< 0) < 0)
return NULL; return NULL;
} }
/* Work around Linux IPv6 weirdness */
if (addr.ss_family == AF_INET6)
addrlen = sizeof(struct sockaddr_in6);
/* Get the address in ascii. */ /* Get the address in ascii. */
if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop),
NULL, 0, flags) != 0) { NULL, 0, flags) != 0) {
@ -319,6 +327,11 @@ get_sock_port(int sock, int local)
fatal_cleanup(); fatal_cleanup();
} }
} }
/* Work around Linux IPv6 weirdness */
if (from.ss_family == AF_INET6)
fromlen = sizeof(struct sockaddr_in6);
/* Return port number. */ /* Return port number. */
if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
strport, sizeof(strport), NI_NUMERICSERV) != 0) strport, sizeof(strport), NI_NUMERICSERV) != 0)