summaryrefslogtreecommitdiffstats
path: root/usr.bin/finger
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2000-09-24 01:54:49 +0000
committerwollman <wollman@FreeBSD.org>2000-09-24 01:54:49 +0000
commit314abdc18465b579175462bc8a5536902d974472 (patch)
tree4d04db4763c0aeb5fd83590c603ae111a31601ad /usr.bin/finger
parent98932a243c747b66c0dd0acc6b3b82e9878a1312 (diff)
downloadFreeBSD-src-314abdc18465b579175462bc8a5536902d974472.zip
FreeBSD-src-314abdc18465b579175462bc8a5536902d974472.tar.gz
Don't assume ai0->ai_canonname will always be filled in. Print the
user-supplied host name if we can't get a canonical name. Obtained from: contrib/tcp_wrappers/socket.c rev. 1.4 (in spirit)
Diffstat (limited to 'usr.bin/finger')
-rw-r--r--usr.bin/finger/net.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c
index 00547ec..427d233 100644
--- a/usr.bin/finger/net.c
+++ b/usr.bin/finger/net.c
@@ -96,7 +96,12 @@ netfinger(name)
}
multi = (ai0->ai_next) != 0;
- printf("[%s]\n", ai0->ai_canonname);
+
+ /* ai_canonname may not be filled in if the user specified an IP. */
+ if (ai0->ai_canonname == 0)
+ printf("[%s]\n", host);
+ else
+ printf("[%s]\n", ai0->ai_canonname);
for (ai = ai0; ai != 0; ai = ai->ai_next) {
if (multi)
OpenPOWER on IntegriCloud