diff options
author | Hajimu UMEMOTO <ume@FreeBSD.org> | 2000-07-14 18:08:19 +0000 |
---|---|---|
committer | Hajimu UMEMOTO <ume@FreeBSD.org> | 2000-07-14 18:08:19 +0000 |
commit | 6484396e9923f5e2aec49b4ba32ebce7ec2eff40 (patch) | |
tree | f85fce2d49f0c7a9c7300aa0710c3e734454f289 /lib/libutil | |
parent | d9a9b8dbb667dc660b06b195745f1d67318df534 (diff) | |
download | src-6484396e9923f5e2aec49b4ba32ebce7ec2eff40.tar.gz src-6484396e9923f5e2aec49b4ba32ebce7ec2eff40.zip |
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.
Notes
Notes:
svn path=/head/; revision=63164
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/realhostname.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c index a0febb81c391..a6f10d689300 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; |