summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/canohost.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-04-23 17:13:13 +0000
committerdes <des@FreeBSD.org>2003-04-23 17:13:13 +0000
commit58b9db3b6f971290d3f183595398923fba625338 (patch)
treefbb17bcf9ee0d969274a32106e1f15ae9a690fa3 /crypto/openssh/canohost.c
parent6d34992e86f885f08b7df6e18a0b6af25ec2d664 (diff)
downloadFreeBSD-src-58b9db3b6f971290d3f183595398923fba625338.zip
FreeBSD-src-58b9db3b6f971290d3f183595398923fba625338.tar.gz
Resolve conflicts.
Diffstat (limited to 'crypto/openssh/canohost.c')
-rw-r--r--crypto/openssh/canohost.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/crypto/openssh/canohost.c b/crypto/openssh/canohost.c
index 1685c7e..aa8c9af 100644
--- a/crypto/openssh/canohost.c
+++ b/crypto/openssh/canohost.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: canohost.c,v 1.34 2002/09/23 20:46:27 stevesk Exp $");
+RCSID("$OpenBSD: canohost.c,v 1.35 2002/11/26 02:38:54 stevesk Exp $");
RCSID("$FreeBSD$");
#include "packet.h"
@@ -39,7 +39,7 @@ get_remote_hostname(int socket, int verify_reverse_mapping)
/* Get IP address of client. */
fromlen = sizeof(from);
memset(&from, 0, sizeof(from));
- if (getpeername(socket, (struct sockaddr *) &from, &fromlen) < 0) {
+ if (getpeername(socket, (struct sockaddr *)&from, &fromlen) < 0) {
debug("getpeername failed: %.100s", strerror(errno));
fatal_cleanup();
}
@@ -60,11 +60,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)
@@ -203,8 +206,8 @@ get_canonical_hostname(int verify_reverse_mapping)
}
/*
- * Returns the remote IP-address of socket as a string. The returned
- * string must be freed.
+ * Returns the local/remote IP-address/hostname of socket as a string.
+ * The returned string must be freed.
*/
static char *
get_socket_address(int socket, int remote, int flags)
@@ -226,10 +229,15 @@ 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) {
- error("get_socket_ipaddr: getnameinfo %d failed", flags);
+ error("get_socket_address: getnameinfo %d failed", flags);
return NULL;
}
return xstrdup(ntop);
@@ -315,11 +323,16 @@ get_sock_port(int sock, int local)
return 0;
}
} else {
- if (getpeername(sock, (struct sockaddr *) & from, &fromlen) < 0) {
+ if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0) {
debug("getpeername failed: %.100s", strerror(errno));
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)
OpenPOWER on IntegriCloud