From f306e0c85fcc9e76547cff084184d0b64abcb2bb Mon Sep 17 00:00:00 2001 From: Yoshinobu Inoue Date: Mon, 7 Feb 2000 00:52:49 +0000 Subject: Fix telnet core dump at invalid service name specified. Added an error check to avoid it. Approved by: jkh Submitted by: Robert Muir --- usr.bin/telnet/commands.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'usr.bin') diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 33a45481667d..b7e81c4935e7 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -2298,6 +2298,12 @@ tn(argc, argv) (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1); _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; + } else if (error != 0) { + fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error)); + if (error == EAI_SYSTEM) + fprintf(stderr, "%s: %s\n", hostname, strerror(errno)); + setuid(getuid()); + return 0; } if (srcroute != 0) { srp = 0; -- cgit v1.3