[2336] in Kerberos-V5-bugs
pending/97: krb5b7: telnet: canonify host name when doing XDISPLOC
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Thu Oct 10 12:59:32 1996
Resent-From: gnats@rt-11.MIT.EDU (GNATS Management)
Resent-To: gnats-admin@rt-11.MIT.EDU
Resent-Reply-To: krb5-bugs@MIT.EDU, "Jonathan I. Kamens" <jik@jik.tiac.net>
Date: Tue, 17 Sep 1996 17:12:17 -0400
From: "Jonathan I. Kamens" <jik@jik.tiac.net>
To: krb5-bugs@MIT.EDU, kerberos@MIT.EDU
>Number: 97
>Category: pending
>Synopsis: krb5b7: telnet: canonify host name when doing XDISPLOC
>Confidential: yes
>Severity: serious
>Priority: medium
>Responsible: gnats-admin
>State: open
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Thu Oct e 12:57:04 EDT 1996
>Last-Modified:
>Originator:
>Organization:
>Release:
>Environment:
>Description:
>How-To-Repeat:
>Fix:
>Audit-Trail:
>Unformatted:
When changing DISPLAY values of the form ":x.x" or "unix:x.x" to
"hostname:x.x" in order to send them to the remote host using the
XDISPLOC option, telnet should call gethostbyname() to fully qualify
the host name, so that it'll be valid even when connecting to a host
in a different domain.
Also, telnet should check the return value of gethostname().
Here's a diff:
--- telnet/commands.c 1996/09/17 19:56:23 1.4
+++ telnet/commands.c 1996/09/17 19:57:31 1.5
@@ -1719,13 +1719,21 @@
|| (strncmp((char *)ep->value, "unix:", 5) == 0))) {
char hbuf[256+1];
char *cp2 = strchr((char *)ep->value, ':');
+
+ if (gethostname(hbuf, 256) == 0) {
+ struct hostent *host;
- gethostname(hbuf, 256);
- hbuf[256] = '\0';
- cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
- sprintf((char *)cp, "%s%s", hbuf, cp2);
- free(ep->value);
- ep->value = (unsigned char *)cp;
+ hbuf[256] = '\0';
+ host = gethostbyname(hbuf);
+ if (host) {
+ strncpy(hbuf, host->h_name, sizeof(hbuf));
+ hbuf[256] = '\0';
+ }
+ cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
+ sprintf((char *)cp, "%s%s", hbuf, cp2);
+ free(ep->value);
+ ep->value = (unsigned char *)cp;
+ }
}
/*
* If USER is not defined, but LOGNAME is, then add