[2667] in Kerberos-V5-bugs
krb5-appl/374: telnet should canonify host name in DISPLAY
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Wed Feb 12 12:32:27 1997
Resent-From: gnats@rt-11.MIT.EDU (GNATS Management)
Resent-To: krb5-unassigned@RT-11.MIT.EDU
Resent-Reply-To: krb5-bugs@MIT.EDU, jik@cam.ov.com
Date: Wed, 12 Feb 1997 12:30:48 -0500
From: "Jonathan I. Kamens" <jik@kamens.brookline.ma.us>
Reply-To: jik@cam.ov.com
To: krb5-bugs@MIT.EDU
Cc: jik@cam.ov.com
>Number: 374
>Category: krb5-appl
>Synopsis: telnet should canonify host name in DISPLAY
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: krb5-unassigned
>State: open
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Wed Feb 12 12:28:00 EST 1997
>Last-Modified:
>Originator: Jonathan I. Kamens
>Organization:
OpenVision Technologies, Inc.
>Release: 1.0
>Environment:
N/A
>Description:
When telnet notices that the DISPLAY environment variable
starts with ":" or "unix:" and goes to prefix it with the local host
name before exporting it to the remote host, it should try to canonify
the local host name, so that the DISPLAY setting will be valid even if
the remote host is in a different domain. Also, it should check the
return value of gethostname() and not try to use it if it failed.
I believe I submitted this patch previously, but it doesn't
seem to have made it into 1.0.
>How-To-Repeat:
>Fix:
--- krb5-1.0/src/appl/telnet/telnet/commands.c Tue Nov 26 20:42:37 1996
+++ krb5-1.0/src/appl/telnet/telnet/commands.c Tue Feb 11 20:31:45 1997
@@ -1727,12 +1727,19 @@
char hbuf[256+1];
char *cp2 = strchr((char *)ep->value, ':');
- 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;
+ if (gethostname(hbuf, 256) == 0) {
+ struct hostent *host;
+
+ 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
>Audit-Trail:
>Unformatted: