From 718ab6235df17d368ba0344f7397cb2cb7e569b2 Mon Sep 17 00:00:00 2001 From: beck <> Date: Tue, 20 Dec 2016 23:14:37 +0000 Subject: 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@ --- src/lib/libcrypto/bio/b_sock.c | 51 +++++------------------------------ src/lib/libcrypto/man/BIO_s_connect.3 | 22 +++------------ 2 files changed, 11 insertions(+), 62 deletions(-) (limited to 'src/lib') 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 @@ -/* $OpenBSD: b_sock.c,v 1.61 2014/12/03 22:14:38 bcook Exp $ */ +/* $OpenBSD: b_sock.c,v 1.62 2016/12/20 23:14:37 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,57 +120,20 @@ BIO_get_port(const char *str, unsigned short *port_ptr) .ai_socktype = SOCK_STREAM, .ai_flags = AI_PASSIVE, }; - long port; - char *ep; + int error; if (str == NULL) { BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_SPECIFIED); return (0); } - errno = 0; - port = strtol(str, &ep, 10); - if (str[0] != '\0' && *ep == '\0') { - if (errno == ERANGE && (port == LONG_MAX || port == LONG_MIN)) { - BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER); - return (0); - } - if (port < 0 || port > 65535) { - BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER); - return (0); - } - goto done; - } - - if (getaddrinfo(NULL, str, &hints, &res) == 0) { - port = ntohs(((struct sockaddr_in *)(res->ai_addr))->sin_port); - goto done; - } - - if (strcmp(str, "http") == 0) - port = 80; - else if (strcmp(str, "telnet") == 0) - port = 23; - else if (strcmp(str, "socks") == 0) - port = 1080; - else if (strcmp(str, "https") == 0) - port = 443; - else if (strcmp(str, "ssl") == 0) - port = 443; - else if (strcmp(str, "ftp") == 0) - port = 21; - else if (strcmp(str, "gopher") == 0) - port = 70; - else { - SYSerr(SYS_F_GETSERVBYNAME, errno); - ERR_asprintf_error_data("service='%s'", str); + if ((error = getaddrinfo(NULL, str, &hints, &res)) != 0) { + ERR_asprintf_error_data("getaddrinfo: service='%s' : %s'", str, + gai_strerror(error)); return (0); } - -done: - if (res) - freeaddrinfo(res); - *port_ptr = (unsigned short)port; + *port_ptr = ntohs(((struct sockaddr_in *)(res->ai_addr))->sin_port); + freeaddrinfo(res); return (1); } 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 @@ -.\" $OpenBSD: BIO_s_connect.3,v 1.5 2016/12/06 14:45:08 schwarze Exp $ +.\" $OpenBSD: BIO_s_connect.3,v 1.6 2016/12/20 23:14:37 beck Exp $ .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 6 2016 $ +.Dd $Mdocdate: December 20 2016 $ .Dt BIO_S_CONNECT 3 .Os .Sh NAME @@ -179,22 +179,8 @@ or sets the port to .Fa port . .Fa port -can be the numerical form or a string such as -.Cm http . -A string will be looked up first using -.Xr getservbyname 3 -on the host platform, but if that fails -a built-in table of port names will be used. -Currently the list is -.Cm http , -.Cm telnet , -.Cm socks , -.Cm https , -.Cm ssl , -.Cm ftp , -.Cm gopher , -and -.Cm wais . +is looked up as a service using +.Xr getaddrinfo 3 .Pp .Fn BIO_set_conn_ip sets the IP address to -- cgit v1.2.3-55-g6feb