diff options
Diffstat (limited to 'sshconnect.c')
-rw-r--r-- | sshconnect.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sshconnect.c b/sshconnect.c index 16db13fa1..33d9c727f 100644 --- a/sshconnect.c +++ b/sshconnect.c | |||
@@ -13,7 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "includes.h" | 15 | #include "includes.h" |
16 | RCSID("$OpenBSD: sshconnect.c,v 1.138 2003/04/08 20:21:29 itojun Exp $"); | 16 | RCSID("$OpenBSD: sshconnect.c,v 1.139 2003/04/14 14:17:50 markus Exp $"); |
17 | 17 | ||
18 | #include <openssl/bn.h> | 18 | #include <openssl/bn.h> |
19 | 19 | ||
@@ -163,7 +163,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) | |||
163 | * Creates a (possibly privileged) socket for use as the ssh connection. | 163 | * Creates a (possibly privileged) socket for use as the ssh connection. |
164 | */ | 164 | */ |
165 | static int | 165 | static int |
166 | ssh_create_socket(int privileged, int family) | 166 | ssh_create_socket(int privileged, struct addrinfo *ai) |
167 | { | 167 | { |
168 | int sock, gaierr; | 168 | int sock, gaierr; |
169 | struct addrinfo hints, *res; | 169 | struct addrinfo hints, *res; |
@@ -175,15 +175,16 @@ ssh_create_socket(int privileged, int family) | |||
175 | if (privileged) { | 175 | if (privileged) { |
176 | int p = IPPORT_RESERVED - 1; | 176 | int p = IPPORT_RESERVED - 1; |
177 | PRIV_START; | 177 | PRIV_START; |
178 | sock = rresvport_af(&p, family); | 178 | sock = rresvport_af(&p, ai->ai_family); |
179 | PRIV_END; | 179 | PRIV_END; |
180 | if (sock < 0) | 180 | if (sock < 0) |
181 | error("rresvport: af=%d %.100s", family, strerror(errno)); | 181 | error("rresvport: af=%d %.100s", ai->ai_family, |
182 | strerror(errno)); | ||
182 | else | 183 | else |
183 | debug("Allocated local port %d.", p); | 184 | debug("Allocated local port %d.", p); |
184 | return sock; | 185 | return sock; |
185 | } | 186 | } |
186 | sock = socket(family, SOCK_STREAM, 0); | 187 | sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); |
187 | if (sock < 0) | 188 | if (sock < 0) |
188 | error("socket: %.100s", strerror(errno)); | 189 | error("socket: %.100s", strerror(errno)); |
189 | 190 | ||
@@ -192,8 +193,9 @@ ssh_create_socket(int privileged, int family) | |||
192 | return sock; | 193 | return sock; |
193 | 194 | ||
194 | memset(&hints, 0, sizeof(hints)); | 195 | memset(&hints, 0, sizeof(hints)); |
195 | hints.ai_family = family; | 196 | hints.ai_family = ai->ai_family; |
196 | hints.ai_socktype = SOCK_STREAM; | 197 | hints.ai_socktype = ai->ai_socktype; |
198 | hints.ai_protocol = ai->ai_protocol; | ||
197 | hints.ai_flags = AI_PASSIVE; | 199 | hints.ai_flags = AI_PASSIVE; |
198 | gaierr = getaddrinfo(options.bind_address, "0", &hints, &res); | 200 | gaierr = getaddrinfo(options.bind_address, "0", &hints, &res); |
199 | if (gaierr) { | 201 | if (gaierr) { |
@@ -295,7 +297,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr, | |||
295 | host, ntop, strport); | 297 | host, ntop, strport); |
296 | 298 | ||
297 | /* Create a socket for connecting. */ | 299 | /* Create a socket for connecting. */ |
298 | sock = ssh_create_socket(needpriv, ai->ai_family); | 300 | sock = ssh_create_socket(needpriv, ai); |
299 | if (sock < 0) | 301 | if (sock < 0) |
300 | /* Any error is already output */ | 302 | /* Any error is already output */ |
301 | continue; | 303 | continue; |