summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeck <>2016-12-20 23:14:37 +0000
committerbeck <>2016-12-20 23:14:37 +0000
commit718ab6235df17d368ba0344f7397cb2cb7e569b2 (patch)
tree5933ca58ab406c9ea7ae2d23761b6e6a0d278eeb /src
parent34e67f293c761ea1fdc5fbb6bcd1a52efa2c1a9d (diff)
downloadopenbsd-718ab6235df17d368ba0344f7397cb2cb7e569b2.tar.gz
openbsd-718ab6235df17d368ba0344f7397cb2cb7e569b2.tar.bz2
openbsd-718ab6235df17d368ba0344f7397cb2cb7e569b2.zip
Delete completely useless crap and just use getaddrinfo. Fix man page
while we're at it. Note for the nostalgic, since "wais" is still an alias in /etc/services it will continue to work.. ok deraadt@ millert@ krw@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bio/b_sock.c51
-rw-r--r--src/lib/libcrypto/man/BIO_s_connect.322
2 files changed, 11 insertions, 62 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index ece88277df..db8a30538c 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.61 2014/12/03 22:14:38 bcook Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.62 2016/12/20 23:14:37 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -120,57 +120,20 @@ BIO_get_port(const char *str, unsigned short *port_ptr)
120 .ai_socktype = SOCK_STREAM, 120 .ai_socktype = SOCK_STREAM,
121 .ai_flags = AI_PASSIVE, 121 .ai_flags = AI_PASSIVE,
122 }; 122 };
123 long port; 123 int error;
124 char *ep;
125 124
126 if (str == NULL) { 125 if (str == NULL) {
127 BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_SPECIFIED); 126 BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_SPECIFIED);
128 return (0); 127 return (0);
129 } 128 }
130 129
131 errno = 0; 130 if ((error = getaddrinfo(NULL, str, &hints, &res)) != 0) {
132 port = strtol(str, &ep, 10); 131 ERR_asprintf_error_data("getaddrinfo: service='%s' : %s'", str,
133 if (str[0] != '\0' && *ep == '\0') { 132 gai_strerror(error));
134 if (errno == ERANGE && (port == LONG_MAX || port == LONG_MIN)) {
135 BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER);
136 return (0);
137 }
138 if (port < 0 || port > 65535) {
139 BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER);
140 return (0);
141 }
142 goto done;
143 }
144
145 if (getaddrinfo(NULL, str, &hints, &res) == 0) {
146 port = ntohs(((struct sockaddr_in *)(res->ai_addr))->sin_port);
147 goto done;
148 }
149
150 if (strcmp(str, "http") == 0)
151 port = 80;
152 else if (strcmp(str, "telnet") == 0)
153 port = 23;
154 else if (strcmp(str, "socks") == 0)
155 port = 1080;
156 else if (strcmp(str, "https") == 0)
157 port = 443;
158 else if (strcmp(str, "ssl") == 0)
159 port = 443;
160 else if (strcmp(str, "ftp") == 0)
161 port = 21;
162 else if (strcmp(str, "gopher") == 0)
163 port = 70;
164 else {
165 SYSerr(SYS_F_GETSERVBYNAME, errno);
166 ERR_asprintf_error_data("service='%s'", str);
167 return (0); 133 return (0);
168 } 134 }
169 135 *port_ptr = ntohs(((struct sockaddr_in *)(res->ai_addr))->sin_port);
170done: 136 freeaddrinfo(res);
171 if (res)
172 freeaddrinfo(res);
173 *port_ptr = (unsigned short)port;
174 return (1); 137 return (1);
175} 138}
176 139
diff --git a/src/lib/libcrypto/man/BIO_s_connect.3 b/src/lib/libcrypto/man/BIO_s_connect.3
index 44ebb19a6c..bde10e4b20 100644
--- a/src/lib/libcrypto/man/BIO_s_connect.3
+++ b/src/lib/libcrypto/man/BIO_s_connect.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_connect.3,v 1.5 2016/12/06 14:45:08 schwarze Exp $ 1.\" $OpenBSD: BIO_s_connect.3,v 1.6 2016/12/20 23:14:37 beck Exp $
2.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 2.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 6 2016 $ 51.Dd $Mdocdate: December 20 2016 $
52.Dt BIO_S_CONNECT 3 52.Dt BIO_S_CONNECT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -179,22 +179,8 @@ or
179sets the port to 179sets the port to
180.Fa port . 180.Fa port .
181.Fa port 181.Fa port
182can be the numerical form or a string such as 182is looked up as a service using
183.Cm http . 183.Xr getaddrinfo 3
184A string will be looked up first using
185.Xr getservbyname 3
186on the host platform, but if that fails
187a built-in table of port names will be used.
188Currently the list is
189.Cm http ,
190.Cm telnet ,
191.Cm socks ,
192.Cm https ,
193.Cm ssl ,
194.Cm ftp ,
195.Cm gopher ,
196and
197.Cm wais .
198.Pp 184.Pp
199.Fn BIO_set_conn_ip 185.Fn BIO_set_conn_ip
200sets the IP address to 186sets the IP address to