summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2000-07-14 18:08:19 +0000
committerume <ume@FreeBSD.org>2000-07-14 18:08:19 +0000
commit3f52ad52cc6e00f2796a471b1ccf01a3d30e86fe (patch)
treea17ae66033e48538fb70d74377770695b828bcfe /lib
parent0fc3455bb5bcc5aab2e5271f562b64950eee64b4 (diff)
downloadFreeBSD-src-3f52ad52cc6e00f2796a471b1ccf01a3d30e86fe.zip
FreeBSD-src-3f52ad52cc6e00f2796a471b1ccf01a3d30e86fe.tar.gz
Sshd writes connected host into utmp directly. If the connection is
via IPv6, the hostname is trimed due to the length of IPv6 address. This change saves it as possible. I have a grudge against the shortage of UT_HOSTSIZE.
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/realhostname.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c
index a0febb8..a6f10d6 100644
--- a/lib/libutil/realhostname.c
+++ b/lib/libutil/realhostname.c
@@ -131,13 +131,20 @@ realhostname_sa(char *host, size_t hsize, struct sockaddr *addr, int addrlen)
freeaddrinfo(ores);
goto numeric;
}
- if (strlen(ores->ai_canonname) > hsize &&
- addr->sa_family == AF_INET) {
- freeaddrinfo(ores);
- goto numeric;
- }
- strncpy(host, ores->ai_canonname,
- hsize);
+ if (strlen(ores->ai_canonname) > hsize) {
+ if (addr->sa_family == AF_INET) {
+ freeaddrinfo(ores);
+ goto numeric;
+ }
+ strncpy(buf,
+ ores->ai_canonname,
+ sizeof(buf));
+ trimdomain(buf, hsize);
+ strncpy(host, buf, hsize);
+ } else
+ strncpy(host,
+ ores->ai_canonname,
+ hsize);
break;
}
((struct sockinet *)addr)->si_port = port;
OpenPOWER on IntegriCloud