diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-08-31 17:41:52 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-08-31 17:41:52 +0000 |
commit | 939a68d5a33bb09f943dad86ce260dc0b245117c (patch) | |
tree | 2289e14080c4c045e0e046b59f4551912dd7cbcc /lib/libc | |
parent | a5d64a989b54f7027852156a479d9deee2429b4e (diff) |
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@mahoroba.org. sync with kame.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/getaddrinfo.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index fc097360bfd..1326473fb74 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -1,5 +1,5 @@ -/* $OpenBSD: getaddrinfo.c,v 1.26 2000/08/22 19:04:42 deraadt Exp $ */ -/* $KAME: getaddrinfo.c,v 1.30 2000/07/09 04:37:25 itojun Exp $ */ +/* $OpenBSD: getaddrinfo.c,v 1.27 2000/08/31 17:41:51 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. @@ -1289,7 +1289,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; @@ -1310,11 +1310,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'; @@ -1334,7 +1337,7 @@ found: 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; } |