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)
This commit is contained in:
wollman 2000-09-24 01:54:49 +00:00
parent 087265d109
commit 3da774a231

View File

@ -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)