Browse files

on /etc/hosts lookup, set "official host name" (the leftmost hostname)

into ai_canonname.  this is to synchronize with practice in gethostby*.
comment from ume.
  • Loading branch information...
1 parent bb1fc40 commit 7760fad330c97ce302c98b4c4a73934958fcd7c5 itojun committed Aug 31, 2000
Showing with 6 additions and 3 deletions.
  1. +6 −3 openbsd/lib/libinet6/getaddrinfo.c
View
9 openbsd/lib/libinet6/getaddrinfo.c
@@ -1,5 +1,5 @@
/* $OpenBSD: getaddrinfo.c,v 1.23 2000/05/15 10:49:55 itojun Exp $ */
-/* $KAME: getaddrinfo.c,v 1.30 2000/07/09 04:37:25 itojun Exp $ */
+/* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -1344,7 +1344,7 @@ _gethtent(name, pai)
const struct addrinfo *pai;
{
char *p;
- char *cp, *tname;
+ char *cp, *tname, *cname;
struct addrinfo hints, *res0, *res;
int error;
const char *addr;
@@ -1365,11 +1365,14 @@ _gethtent(name, pai)
*cp++ = '\0';
addr = p;
/* if this is not something we're looking for, skip it. */
+ cname = NULL;
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
+ if (!cname)
+ cname = cp;
tname = cp;
if ((cp = strpbrk(cp, " \t")) != NULL)
*cp++ = '\0';
@@ -1397,7 +1400,7 @@ _gethtent(name, pai)
res->ai_flags = pai->ai_flags;
if (pai->ai_flags & AI_CANONNAME) {
- if (get_canonname(pai, res, name) != 0) {
+ if (get_canonname(pai, res, cname) != 0) {
freeaddrinfo(res0);
goto again;
}

0 comments on commit 7760fad

Please sign in to comment.