From f6e4b512268b34b2ef255f71519296a62018537d Mon Sep 17 00:00:00 2001 From: itojun <> Date: Thu, 31 Aug 2000 17:41:51 +0000 Subject: 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. --- src/lib/libc/net/getaddrinfo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c index fc097360bf..1326473fb7 100644 --- a/src/lib/libc/net/getaddrinfo.c +++ b/src/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; } -- cgit v1.2.3-55-g6feb