* commands.c (tn): Don't crash printing null hostname in case where supplied
authorKen Raeburn <raeburn@mit.edu>
Fri, 7 Sep 2001 14:58:06 +0000 (14:58 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 7 Sep 2001 14:58:06 +0000 (14:58 +0000)
destination is a numeric address that doesn't map to a hostname.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13739 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/telnet/telnet/ChangeLog
src/appl/telnet/telnet/commands.c

index b10f245ed6cb0827e0e05ed85c0f05dec9ea9ccb..17817386e14920ef0c8525755c4fb897449ee6fe 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-07  Ken Raeburn  <raeburn@mit.edu>
+
+       * commands.c (tn): Don't crash printing null hostname in case
+       where supplied destination is a numeric address that doesn't map
+       to a hostname.
+
 2001-09-01  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (SRCS): Use $(srcdir).
index ef4d3eeca11387c622e3c3307b22002c469d2758..855bf242515f8d3e52df99b02708f6b903b10ec8 100644 (file)
@@ -2529,8 +2529,9 @@ tn(argc, argv)
        error = getaddrinfo (hostp, portp, &hints, &addrs);
        if (error == 0) {
            if (getnameinfo (addrs->ai_addr, addrs->ai_addrlen,
-                            _hostname, sizeof(_hostname), 0, 0, NI_NAMEREQD) == 0)
-               hostname = _hostname;
+                            _hostname, sizeof(_hostname), 0, 0, NI_NAMEREQD) != 0)
+               strncpy(_hostname, hostp, sizeof (_hostname));
+           hostname = _hostname;
        } else {
        not_numeric:
            hints.ai_flags = AI_CANONNAME;