Skip to content

Commit

Permalink
on /etc/hosts lookup, set "official host name" (the leftmost hostname)
Browse files Browse the repository at this point in the history
into ai_canonname.  this is to synchronize with practice in gethostby*.
comment from ume.
  • Loading branch information
itojun committed Aug 31, 2000
1 parent bb1fc40 commit 7760fad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions openbsd/lib/libinet6/getaddrinfo.c
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* $OpenBSD: getaddrinfo.c,v 1.23 2000/05/15 10:49:55 itojun Exp $ */ /* $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. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -1344,7 +1344,7 @@ _gethtent(name, pai)
const struct addrinfo *pai; const struct addrinfo *pai;
{ {
char *p; char *p;
char *cp, *tname; char *cp, *tname, *cname;
struct addrinfo hints, *res0, *res; struct addrinfo hints, *res0, *res;
int error; int error;
const char *addr; const char *addr;
Expand All @@ -1365,11 +1365,14 @@ _gethtent(name, pai)
*cp++ = '\0'; *cp++ = '\0';
addr = p; addr = p;
/* if this is not something we're looking for, skip it. */ /* if this is not something we're looking for, skip it. */
cname = NULL;
while (cp && *cp) { while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') { if (*cp == ' ' || *cp == '\t') {
cp++; cp++;
continue; continue;
} }
if (!cname)
cname = cp;
tname = cp; tname = cp;
if ((cp = strpbrk(cp, " \t")) != NULL) if ((cp = strpbrk(cp, " \t")) != NULL)
*cp++ = '\0'; *cp++ = '\0';
Expand Down Expand Up @@ -1397,7 +1400,7 @@ _gethtent(name, pai)
res->ai_flags = pai->ai_flags; res->ai_flags = pai->ai_flags;


if (pai->ai_flags & AI_CANONNAME) { if (pai->ai_flags & AI_CANONNAME) {
if (get_canonname(pai, res, name) != 0) { if (get_canonname(pai, res, cname) != 0) {
freeaddrinfo(res0); freeaddrinfo(res0);
goto again; goto again;
} }
Expand Down

0 comments on commit 7760fad

Please sign in to comment.