diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-30 23:57:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-30 23:57:09 +0000 |
commit | 03d411d0c93a6e668ca2efa294619aa3e48f5bc6 (patch) | |
tree | 7ab5dcdbbc7efb838f1e083a7cbc67f48459c3fd /usr.bin/telnet | |
parent | 09941788c77692bf2a578aacaf9423aea7a194d8 (diff) |
If getaddrinfo() fails:
o Only call herror() if h_errno != 0
o if error == EAI_SERVICE say "bad port" since the generic error,
"service not supported for ai_socktype" is incomprehensible to most
users.
o Use warnx(), not warn() since this is not a case where errno is likely
to be relevant.
Ok'd by Theo
Diffstat (limited to 'usr.bin/telnet')
-rw-r--r-- | usr.bin/telnet/commands.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 578c300a3ed..d11f8de5c66 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.27 2000/02/05 18:17:56 itojun Exp $ */ +/* $OpenBSD: commands.c,v 1.28 2000/04/30 23:57:08 millert Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -2375,10 +2375,15 @@ tn(argc, argv) portp++; telnetport = 1; } + h_errno = 0; error = getaddrinfo(hostp, portp, &hints, &res0); if (error) { - warn("%s: %s", hostp, gai_strerror(error)); - herror(hostp); + if (error == EAI_SERVICE) + warnx("%s: bad port", portp); + else + warnx("%s: %s", hostp, gai_strerror(error)); + if (h_errno) + herror(hostp); return 0; } } |