Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
do not glob socktype/protocol twice.
  • Loading branch information
itojun committed Jan 6, 2001
1 parent 8e26dfd commit cb03024
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
12 changes: 9 additions & 3 deletions freebsd4/lib/libinet6/getaddrinfo.c
@@ -1,4 +1,4 @@
/* $KAME: getaddrinfo.c,v 1.26 2001/01/06 09:44:52 jinmei Exp $ */
/* $KAME: getaddrinfo.c,v 1.27 2001/01/06 16:01:15 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -1623,9 +1623,13 @@ _gethtent(hostf, name, pai)
goto again;

found:
hints = *pai;
/* we should not glob socktype/protocol here */
memset(&hints, 0, sizeof(hints));
hints.ai_family = pai->ai_family;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_NUMERICHOST;
error = getaddrinfo(addr, NULL, &hints, &res0);
error = getaddrinfo(addr, "0", &hints, &res0);
if (error)
goto again;
#ifdef FILTER_V4MAPPED
Expand All @@ -1639,6 +1643,8 @@ _gethtent(hostf, name, pai)
for (res = res0; res; res = res->ai_next) {
/* cover it up */
res->ai_flags = pai->ai_flags;
res->ai_socktype = pai->ai_socktype;
res->ai_protocol = pai->ai_protocol;

if (pai->ai_flags & AI_CANONNAME) {
if (get_canonname(pai, res, cname) != 0) {
Expand Down
22 changes: 17 additions & 5 deletions 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.41 2001/01/06 09:43:18 jinmei Exp $ */
/* $KAME: getaddrinfo.c,v 1.42 2001/01/06 15:59:52 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -1466,9 +1466,13 @@ _gethtent(name, pai)
goto again;

found:
hints = *pai;
/* we should not glob socktype/protocol here */
memset(&hints, 0, sizeof(hints));
hints.ai_family = pai->ai_family;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_NUMERICHOST;
error = getaddrinfo(addr, NULL, &hints, &res0);
error = getaddrinfo(addr, "0", &hints, &res0);
if (error)
goto again;
#ifdef FILTER_V4MAPPED
Expand All @@ -1482,6 +1486,8 @@ _gethtent(name, pai)
for (res = res0; res; res = res->ai_next) {
/* cover it up */
res->ai_flags = pai->ai_flags;
res->ai_socktype = pai->ai_socktype;
res->ai_protocol = pai->ai_protocol;

if (pai->ai_flags & AI_CANONNAME) {
if (get_canonname(pai, res, cname) != 0) {
Expand Down Expand Up @@ -1569,9 +1575,13 @@ _yphostent(line, pai)
*cp++ = '\0';
}

hints = *pai;
/* we should not glob socktype/protocol here */
memset(&hints, 0, sizeof(hints));
hints.ai_family = pai->ai_family;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_NUMERICHOST;
error = getaddrinfo(addr, NULL, &hints, &res0);
error = getaddrinfo(addr, "0", &hints, &res0);
if (error == 0) {
#ifdef FILER_V4MAPPED
/* XXX should check all items in the chain */
Expand All @@ -1584,6 +1594,8 @@ _yphostent(line, pai)
for (res = res0; res; res = res->ai_next) {
/* cover it up */
res->ai_flags = pai->ai_flags;
res->ai_socktype = pai->ai_socktype;
res->ai_protocol = pai->ai_protocol;

if (pai->ai_flags & AI_CANONNAME)
(void)get_canonname(pai, res, canonname);
Expand Down

0 comments on commit cb03024

Please sign in to comment.