diff options
author | itojun <itojun@FreeBSD.org> | 2000-07-07 12:35:05 +0000 |
---|---|---|
committer | itojun <itojun@FreeBSD.org> | 2000-07-07 12:35:05 +0000 |
commit | 1fcab4244d72f94a49fd8023d9fc08a69976dd2f (patch) | |
tree | 679716c572c499fffb68c88c94ae5eb116a1d573 /crypto/telnet | |
parent | aa8afafd98b07d999cdd355b0d219812d2304502 (diff) | |
download | FreeBSD-src-1fcab4244d72f94a49fd8023d9fc08a69976dd2f.zip FreeBSD-src-1fcab4244d72f94a49fd8023d9fc08a69976dd2f.tar.gz |
sync with usr.bin/telnet/commands.c 1.21 -> 1.22. pierre.dampure@alveley.org
Diffstat (limited to 'crypto/telnet')
-rw-r--r-- | crypto/telnet/telnet/commands.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/crypto/telnet/telnet/commands.c b/crypto/telnet/telnet/commands.c index dadc5e5..bc683c7 100644 --- a/crypto/telnet/telnet/commands.c +++ b/crypto/telnet/telnet/commands.c @@ -2468,7 +2468,19 @@ tn(argc, argv) hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(hostname, portp, &hints, &res); - if (error == 0) { + if (error) { + hints.ai_flags = AI_CANONNAME; + error = getaddrinfo(hostname, portp, &hints, &res); + } + 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()); + goto fail; + } + if (hints.ai_flags == AI_NUMERICHOST) { + /* hostname has numeric */ int gni_err = 1; if (doaddrlookup) @@ -2476,19 +2488,11 @@ tn(argc, argv) _hostname, sizeof(_hostname) - 1, NULL, 0, NI_NAMEREQD); if (gni_err != 0) - (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1); + (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1); _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; - } else if (error == EAI_NONAME) { - hints.ai_flags = AI_CANONNAME; - error = getaddrinfo(hostname, portp, &hints, &res); - 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()); - goto fail; - } + } else { + /* hostname has FQDN */ if (srcroute != 0) (void) strncpy(_hostname, hostname, sizeof(_hostname) - 1); else if (res->ai_canonname != NULL) @@ -2497,12 +2501,6 @@ 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()); - goto fail; } res0 = res; af_again: |