From 584a429a9349a9fb6f1140d28e343c403e37b6da Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 7 Sep 2001 14:58:06 +0000 Subject: [PATCH] * 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13739 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/telnet/telnet/ChangeLog | 6 ++++++ src/appl/telnet/telnet/commands.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/appl/telnet/telnet/ChangeLog b/src/appl/telnet/telnet/ChangeLog index b10f245ed..17817386e 100644 --- a/src/appl/telnet/telnet/ChangeLog +++ b/src/appl/telnet/telnet/ChangeLog @@ -1,3 +1,9 @@ +2001-09-07 Ken Raeburn + + * 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 * Makefile.in (SRCS): Use $(srcdir). diff --git a/src/appl/telnet/telnet/commands.c b/src/appl/telnet/telnet/commands.c index ef4d3eeca..855bf2425 100644 --- a/src/appl/telnet/telnet/commands.c +++ b/src/appl/telnet/telnet/commands.c @@ -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; -- 2.26.2