|
1 # |
|
2 # This is to fix a regression in OpenSSH6.5p1 for UsePrivilegedPort=yes. The |
|
3 # bug fix code came from OpenSSH.org. When we upgrade OpenSSH to version 6.6 |
|
4 # or later, we will remove this patch file. |
|
5 # |
|
6 --- orig/sshconnect.c Mon Feb 10 13:56:07 2014 |
|
7 +++ new/sshconnect.c Mon Feb 10 17:10:54 2014 |
|
8 @@ -269,7 +269,7 @@ |
|
9 ssh_create_socket(int privileged, struct addrinfo *ai) |
|
10 { |
|
11 int sock, r, gaierr; |
|
12 - struct addrinfo hints, *res; |
|
13 + struct addrinfo hints, *res = NULL; |
|
14 |
|
15 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); |
|
16 if (sock < 0) { |
|
17 @@ -282,17 +282,19 @@ |
|
18 if (options.bind_address == NULL && !privileged) |
|
19 return sock; |
|
20 |
|
21 - memset(&hints, 0, sizeof(hints)); |
|
22 - hints.ai_family = ai->ai_family; |
|
23 - hints.ai_socktype = ai->ai_socktype; |
|
24 - hints.ai_protocol = ai->ai_protocol; |
|
25 - hints.ai_flags = AI_PASSIVE; |
|
26 - gaierr = getaddrinfo(options.bind_address, NULL, &hints, &res); |
|
27 - if (gaierr) { |
|
28 + if (options.bind_address) { |
|
29 + memset(&hints, 0, sizeof(hints)); |
|
30 + hints.ai_family = ai->ai_family; |
|
31 + hints.ai_socktype = ai->ai_socktype; |
|
32 + hints.ai_protocol = ai->ai_protocol; |
|
33 + hints.ai_flags = AI_PASSIVE; |
|
34 + gaierr = getaddrinfo(options.bind_address, NULL, &hints, &res); |
|
35 + if (gaierr) { |
|
36 error("getaddrinfo: %s: %s", options.bind_address, |
|
37 ssh_gai_strerror(gaierr)); |
|
38 close(sock); |
|
39 return -1; |
|
40 + } |
|
41 } |
|
42 /* |
|
43 * If we are running as root and want to connect to a privileged |
|
44 @@ -300,7 +302,7 @@ |
|
45 */ |
|
46 if (privileged) { |
|
47 PRIV_START; |
|
48 - r = bindresvport_sa(sock, res->ai_addr); |
|
49 + r = bindresvport_sa(sock, res ? res->ai_addr : NULL); |
|
50 PRIV_END; |
|
51 if (r < 0) { |
|
52 error("bindresvport_sa: af=%d %s", ai->ai_family, |
|
53 @@ -317,7 +319,8 @@ |
|
54 return -1; |
|
55 } |
|
56 } |
|
57 - freeaddrinfo(res); |
|
58 + if (res != NULL) |
|
59 + freeaddrinfo(res); |
|
60 return sock; |
|
61 } |
|
62 |