diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | openbsd-compat/fake-getaddrinfo.c | 23 |
2 files changed, 19 insertions, 7 deletions
@@ -83,6 +83,7 @@ | |||
83 | --with-pam | 83 | --with-pam |
84 | - (djm) Die screaming if start_pam() is called when UsePAM=no | 84 | - (djm) Die screaming if start_pam() is called when UsePAM=no |
85 | - (djm) Avoid KrbV leak for MIT Kerberos | 85 | - (djm) Avoid KrbV leak for MIT Kerberos |
86 | - (dtucker) Set ai_socktype and ai_protocol in fake-getaddrinfo.c. ok djm@ | ||
86 | 87 | ||
87 | 20030512 | 88 | 20030512 |
88 | - (djm) Redhat spec: Don't install profile.d scripts when not | 89 | - (djm) Redhat spec: Don't install profile.d scripts when not |
@@ -1470,4 +1471,4 @@ | |||
1470 | save auth method before monitor_reset_key_state(); bugzilla bug #284; | 1471 | save auth method before monitor_reset_key_state(); bugzilla bug #284; |
1471 | ok provos@ | 1472 | ok provos@ |
1472 | 1473 | ||
1473 | $Id: ChangeLog,v 1.2698 2003/05/14 09:31:12 djm Exp $ | 1474 | $Id: ChangeLog,v 1.2699 2003/05/14 11:48:51 dtucker Exp $ |
diff --git a/openbsd-compat/fake-getaddrinfo.c b/openbsd-compat/fake-getaddrinfo.c index e63bda970..34e1fce78 100644 --- a/openbsd-compat/fake-getaddrinfo.c +++ b/openbsd-compat/fake-getaddrinfo.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | #include "ssh.h" | 13 | #include "ssh.h" |
14 | 14 | ||
15 | RCSID("$Id: fake-getaddrinfo.c,v 1.5 2003/03/24 02:35:59 djm Exp $"); | 15 | RCSID("$Id: fake-getaddrinfo.c,v 1.6 2003/05/14 11:48:51 dtucker Exp $"); |
16 | 16 | ||
17 | #ifndef HAVE_GAI_STRERROR | 17 | #ifndef HAVE_GAI_STRERROR |
18 | char *gai_strerror(int ecode) | 18 | char *gai_strerror(int ecode) |
@@ -41,7 +41,8 @@ void freeaddrinfo(struct addrinfo *ai) | |||
41 | #endif /* !HAVE_FREEADDRINFO */ | 41 | #endif /* !HAVE_FREEADDRINFO */ |
42 | 42 | ||
43 | #ifndef HAVE_GETADDRINFO | 43 | #ifndef HAVE_GETADDRINFO |
44 | static struct addrinfo *malloc_ai(int port, u_long addr) | 44 | static struct addrinfo *malloc_ai(int port, u_long addr, |
45 | const struct addrinfo *hints) | ||
45 | { | 46 | { |
46 | struct addrinfo *ai; | 47 | struct addrinfo *ai; |
47 | 48 | ||
@@ -59,6 +60,15 @@ static struct addrinfo *malloc_ai(int port, u_long addr) | |||
59 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; | 60 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; |
60 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; | 61 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; |
61 | 62 | ||
63 | /* XXX: the following is not generally correct, but does what we want */ | ||
64 | if (hints->ai_socktype) | ||
65 | ai->ai_socktype = hints->ai_socktype; | ||
66 | else | ||
67 | ai->ai_socktype = SOCK_STREAM; | ||
68 | |||
69 | if (hints->ai_protocol) | ||
70 | ai->ai_protocol = hints->ai_protocol; | ||
71 | |||
62 | return(ai); | 72 | return(ai); |
63 | } | 73 | } |
64 | 74 | ||
@@ -90,21 +100,21 @@ int getaddrinfo(const char *hostname, const char *servname, | |||
90 | addr = htonl(0x00000000); | 100 | addr = htonl(0x00000000); |
91 | if (hostname && inet_aton(hostname, &in) != 0) | 101 | if (hostname && inet_aton(hostname, &in) != 0) |
92 | addr = in.s_addr; | 102 | addr = in.s_addr; |
93 | if (NULL != (*res = malloc_ai(port, addr))) | 103 | if (NULL != (*res = malloc_ai(port, addr, hints))) |
94 | return 0; | 104 | return 0; |
95 | else | 105 | else |
96 | return EAI_MEMORY; | 106 | return EAI_MEMORY; |
97 | } | 107 | } |
98 | 108 | ||
99 | if (!hostname) { | 109 | if (!hostname) { |
100 | if (NULL != (*res = malloc_ai(port, htonl(0x7f000001)))) | 110 | if (NULL != (*res = malloc_ai(port, htonl(0x7f000001), hints))) |
101 | return 0; | 111 | return 0; |
102 | else | 112 | else |
103 | return EAI_MEMORY; | 113 | return EAI_MEMORY; |
104 | } | 114 | } |
105 | 115 | ||
106 | if (inet_aton(hostname, &in)) { | 116 | if (inet_aton(hostname, &in)) { |
107 | if (NULL != (*res = malloc_ai(port, in.s_addr))) | 117 | if (NULL != (*res = malloc_ai(port, in.s_addr, hints))) |
108 | return 0; | 118 | return 0; |
109 | else | 119 | else |
110 | return EAI_MEMORY; | 120 | return EAI_MEMORY; |
@@ -113,7 +123,8 @@ int getaddrinfo(const char *hostname, const char *servname, | |||
113 | hp = gethostbyname(hostname); | 123 | hp = gethostbyname(hostname); |
114 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { | 124 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { |
115 | for (i = 0; hp->h_addr_list[i]; i++) { | 125 | for (i = 0; hp->h_addr_list[i]; i++) { |
116 | cur = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr); | 126 | cur = malloc_ai(port, |
127 | ((struct in_addr *)hp->h_addr_list[i])->s_addr, hints); | ||
117 | if (cur == NULL) { | 128 | if (cur == NULL) { |
118 | if (*res) | 129 | if (*res) |
119 | freeaddrinfo(*res); | 130 | freeaddrinfo(*res); |