- djm@cvs.openbsd.org 2014/02/06 22:21:01
[sshconnect.c] in ssh_create_socket(), only do the getaddrinfo for BindAddress when BindAddress is actually specified. Fixes regression in 6.5 for UsePrivilegedPort=yes; patch from Corinna Vinschen
This commit is contained in:
parent
6ce35b6cc4
commit
d1a7a9c0fd
|
@ -4,6 +4,11 @@
|
||||||
[ssh-keygen.1 ssh-keygen.c]
|
[ssh-keygen.1 ssh-keygen.c]
|
||||||
tweak synopsis: calling ssh-keygen without any arguments is fine; ok jmc@
|
tweak synopsis: calling ssh-keygen without any arguments is fine; ok jmc@
|
||||||
while here, fix ordering in usage(); requested by jmc@
|
while here, fix ordering in usage(); requested by jmc@
|
||||||
|
- djm@cvs.openbsd.org 2014/02/06 22:21:01
|
||||||
|
[sshconnect.c]
|
||||||
|
in ssh_create_socket(), only do the getaddrinfo for BindAddress when
|
||||||
|
BindAddress is actually specified. Fixes regression in 6.5 for
|
||||||
|
UsePrivilegedPort=yes; patch from Corinna Vinschen
|
||||||
|
|
||||||
20140206
|
20140206
|
||||||
- (dtucker) [openbsd-compat/bsd-poll.c] Don't bother checking for non-NULL
|
- (dtucker) [openbsd-compat/bsd-poll.c] Don't bother checking for non-NULL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sshconnect.c,v 1.245 2014/02/02 03:44:31 djm Exp $ */
|
/* $OpenBSD: sshconnect.c,v 1.246 2014/02/06 22:21:01 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -269,7 +269,7 @@ static int
|
||||||
ssh_create_socket(int privileged, struct addrinfo *ai)
|
ssh_create_socket(int privileged, struct addrinfo *ai)
|
||||||
{
|
{
|
||||||
int sock, r, gaierr;
|
int sock, r, gaierr;
|
||||||
struct addrinfo hints, *res;
|
struct addrinfo hints, *res = NULL;
|
||||||
|
|
||||||
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
|
@ -282,6 +282,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
|
||||||
if (options.bind_address == NULL && !privileged)
|
if (options.bind_address == NULL && !privileged)
|
||||||
return sock;
|
return sock;
|
||||||
|
|
||||||
|
if (options.bind_address) {
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = ai->ai_family;
|
hints.ai_family = ai->ai_family;
|
||||||
hints.ai_socktype = ai->ai_socktype;
|
hints.ai_socktype = ai->ai_socktype;
|
||||||
|
@ -294,13 +295,14 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
|
||||||
close(sock);
|
close(sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* If we are running as root and want to connect to a privileged
|
* If we are running as root and want to connect to a privileged
|
||||||
* port, bind our own socket to a privileged port.
|
* port, bind our own socket to a privileged port.
|
||||||
*/
|
*/
|
||||||
if (privileged) {
|
if (privileged) {
|
||||||
PRIV_START;
|
PRIV_START;
|
||||||
r = bindresvport_sa(sock, res->ai_addr);
|
r = bindresvport_sa(sock, res ? res->ai_addr : NULL);
|
||||||
PRIV_END;
|
PRIV_END;
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
error("bindresvport_sa: af=%d %s", ai->ai_family,
|
error("bindresvport_sa: af=%d %s", ai->ai_family,
|
||||||
|
@ -317,6 +319,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (res != NULL)
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue