summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritojun <>2000-08-31 17:41:51 +0000
committeritojun <>2000-08-31 17:41:51 +0000
commitf6e4b512268b34b2ef255f71519296a62018537d (patch)
tree04b2f07c06f0512366a18bd32f8f7fa04f664f7a
parent5a4c87da3ac47eee8dfc7d3063cd82adc978f804 (diff)
downloadopenbsd-f6e4b512268b34b2ef255f71519296a62018537d.tar.gz
openbsd-f6e4b512268b34b2ef255f71519296a62018537d.tar.bz2
openbsd-f6e4b512268b34b2ef255f71519296a62018537d.zip
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.
-rw-r--r--src/lib/libc/net/getaddrinfo.c11
1 files changed, 7 insertions, 4 deletions
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 @@
1/* $OpenBSD: getaddrinfo.c,v 1.26 2000/08/22 19:04:42 deraadt Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.27 2000/08/31 17:41:51 itojun Exp $ */
2/* $KAME: getaddrinfo.c,v 1.30 2000/07/09 04:37:25 itojun Exp $ */ 2/* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -1289,7 +1289,7 @@ _gethtent(name, pai)
1289 const struct addrinfo *pai; 1289 const struct addrinfo *pai;
1290{ 1290{
1291 char *p; 1291 char *p;
1292 char *cp, *tname; 1292 char *cp, *tname, *cname;
1293 struct addrinfo hints, *res0, *res; 1293 struct addrinfo hints, *res0, *res;
1294 int error; 1294 int error;
1295 const char *addr; 1295 const char *addr;
@@ -1310,11 +1310,14 @@ _gethtent(name, pai)
1310 *cp++ = '\0'; 1310 *cp++ = '\0';
1311 addr = p; 1311 addr = p;
1312 /* if this is not something we're looking for, skip it. */ 1312 /* if this is not something we're looking for, skip it. */
1313 cname = NULL;
1313 while (cp && *cp) { 1314 while (cp && *cp) {
1314 if (*cp == ' ' || *cp == '\t') { 1315 if (*cp == ' ' || *cp == '\t') {
1315 cp++; 1316 cp++;
1316 continue; 1317 continue;
1317 } 1318 }
1319 if (!cname)
1320 cname = cp;
1318 tname = cp; 1321 tname = cp;
1319 if ((cp = strpbrk(cp, " \t")) != NULL) 1322 if ((cp = strpbrk(cp, " \t")) != NULL)
1320 *cp++ = '\0'; 1323 *cp++ = '\0';
@@ -1334,7 +1337,7 @@ found:
1334 res->ai_flags = pai->ai_flags; 1337 res->ai_flags = pai->ai_flags;
1335 1338
1336 if (pai->ai_flags & AI_CANONNAME) { 1339 if (pai->ai_flags & AI_CANONNAME) {
1337 if (get_canonname(pai, res, name) != 0) { 1340 if (get_canonname(pai, res, cname) != 0) {
1338 freeaddrinfo(res0); 1341 freeaddrinfo(res0);
1339 goto again; 1342 goto again;
1340 } 1343 }