Subject: bin/1946: rlogind truncates long remote hostnames
To: None <>
From: Dave Huang <>
List: netbsd-bugs
Date: 01/15/1996 14:59:21
>Number:         1946
>Category:       bin
>Synopsis:       rlogind truncates long remote hostnames
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 15 16:20:05 1996
>Originator:     Dave Huang
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet:   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 20 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of Jan 15, 1996
System: NetBSD 1.1A NetBSD 1.1A (SPIFF) #5: Sun Jan 14 19:31:53 CST 1996 i386

When someone rlogins from another machine, the remote machine name
that gets put into utmp and wtmp gets truncated if it's longer than 16
characters. On the other hand, telnetd will log the IP address instead
of the hostname if it's too long to fit in utmp.
rlogin from a machine that has a >16 character hostname and do a "who"
or "last".

Here's a patch that makes rlogind log the IP address if the hostname
is too long:

--- /usr/src/libexec/rlogind/rlogind.c  Fri Oct 13 20:05:42 1995
+++ rlogind.c   Mon Jan 15 13:18:24 1996
@@ -72,6 +72,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <utmp.h>
 #include "pathnames.h"
@@ -178,7 +179,7 @@
        fromp->sin_port = ntohs((u_short)fromp->sin_port);
        hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr),
-       if (hp)
+       if (hp && (strlen(hp->h_name) <= UT_HOSTSIZE))
                (void)strcpy(hostname, hp->h_name);
                (void)strcpy(hostname, inet_ntoa(fromp->sin_addr));