summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sshconnect.c33
2 files changed, 23 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index cdb5ca4de..e3b5fd28a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@
4 [ssh-keygen.1 ssh-keygen.c] 4 [ssh-keygen.1 ssh-keygen.c]
5 tweak synopsis: calling ssh-keygen without any arguments is fine; ok jmc@ 5 tweak synopsis: calling ssh-keygen without any arguments is fine; ok jmc@
6 while here, fix ordering in usage(); requested by jmc@ 6 while here, fix ordering in usage(); requested by jmc@
7 - djm@cvs.openbsd.org 2014/02/06 22:21:01
8 [sshconnect.c]
9 in ssh_create_socket(), only do the getaddrinfo for BindAddress when
10 BindAddress is actually specified. Fixes regression in 6.5 for
11 UsePrivilegedPort=yes; patch from Corinna Vinschen
7 12
820140206 1320140206
9 - (dtucker) [openbsd-compat/bsd-poll.c] Don't bother checking for non-NULL 14 - (dtucker) [openbsd-compat/bsd-poll.c] Don't bother checking for non-NULL
diff --git a/sshconnect.c b/sshconnect.c
index 3781eaf3b..573d7a8e8 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.245 2014/02/02 03:44:31 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.246 2014/02/06 22:21:01 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -269,7 +269,7 @@ static int
269ssh_create_socket(int privileged, struct addrinfo *ai) 269ssh_create_socket(int privileged, struct addrinfo *ai)
270{ 270{
271 int sock, r, gaierr; 271 int sock, r, gaierr;
272 struct addrinfo hints, *res; 272 struct addrinfo hints, *res = NULL;
273 273
274 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 274 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
275 if (sock < 0) { 275 if (sock < 0) {
@@ -282,17 +282,19 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
282 if (options.bind_address == NULL && !privileged) 282 if (options.bind_address == NULL && !privileged)
283 return sock; 283 return sock;
284 284
285 memset(&hints, 0, sizeof(hints)); 285 if (options.bind_address) {
286 hints.ai_family = ai->ai_family; 286 memset(&hints, 0, sizeof(hints));
287 hints.ai_socktype = ai->ai_socktype; 287 hints.ai_family = ai->ai_family;
288 hints.ai_protocol = ai->ai_protocol; 288 hints.ai_socktype = ai->ai_socktype;
289 hints.ai_flags = AI_PASSIVE; 289 hints.ai_protocol = ai->ai_protocol;
290 gaierr = getaddrinfo(options.bind_address, NULL, &hints, &res); 290 hints.ai_flags = AI_PASSIVE;
291 if (gaierr) { 291 gaierr = getaddrinfo(options.bind_address, NULL, &hints, &res);
292 error("getaddrinfo: %s: %s", options.bind_address, 292 if (gaierr) {
293 ssh_gai_strerror(gaierr)); 293 error("getaddrinfo: %s: %s", options.bind_address,
294 close(sock); 294 ssh_gai_strerror(gaierr));
295 return -1; 295 close(sock);
296 return -1;
297 }
296 } 298 }
297 /* 299 /*
298 * If we are running as root and want to connect to a privileged 300 * If we are running as root and want to connect to a privileged
@@ -300,7 +302,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
300 */ 302 */
301 if (privileged) { 303 if (privileged) {
302 PRIV_START; 304 PRIV_START;
303 r = bindresvport_sa(sock, res->ai_addr); 305 r = bindresvport_sa(sock, res ? res->ai_addr : NULL);
304 PRIV_END; 306 PRIV_END;
305 if (r < 0) { 307 if (r < 0) {
306 error("bindresvport_sa: af=%d %s", ai->ai_family, 308 error("bindresvport_sa: af=%d %s", ai->ai_family,
@@ -317,7 +319,8 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
317 return -1; 319 return -1;
318 } 320 }
319 } 321 }
320 freeaddrinfo(res); 322 if (res != NULL)
323 freeaddrinfo(res);
321 return sock; 324 return sock;
322} 325}
323 326