diff options
| author | beck <> | 2016-12-20 23:14:37 +0000 |
|---|---|---|
| committer | beck <> | 2016-12-20 23:14:37 +0000 |
| commit | 116818f5128b40cefcc5d534e399c4feccf9fae0 (patch) | |
| tree | 5933ca58ab406c9ea7ae2d23761b6e6a0d278eeb /src/lib/libc | |
| parent | e8f139e50a4f35dfb0c10576137a0714ba0a92f6 (diff) | |
| download | openbsd-116818f5128b40cefcc5d534e399c4feccf9fae0.tar.gz openbsd-116818f5128b40cefcc5d534e399c4feccf9fae0.tar.bz2 openbsd-116818f5128b40cefcc5d534e399c4feccf9fae0.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 '')
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 51 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/BIO_s_connect.3 | 22 |
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); | |
| 170 | done: | 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 | |||
| 179 | sets the port to | 179 | sets the port to |
| 180 | .Fa port . | 180 | .Fa port . |
| 181 | .Fa port | 181 | .Fa port |
| 182 | can be the numerical form or a string such as | 182 | is looked up as a service using |
| 183 | .Cm http . | 183 | .Xr getaddrinfo 3 |
| 184 | A string will be looked up first using | ||
| 185 | .Xr getservbyname 3 | ||
| 186 | on the host platform, but if that fails | ||
| 187 | a built-in table of port names will be used. | ||
| 188 | Currently the list is | ||
| 189 | .Cm http , | ||
| 190 | .Cm telnet , | ||
| 191 | .Cm socks , | ||
| 192 | .Cm https , | ||
| 193 | .Cm ssl , | ||
| 194 | .Cm ftp , | ||
| 195 | .Cm gopher , | ||
| 196 | and | ||
| 197 | .Cm wais . | ||
| 198 | .Pp | 184 | .Pp |
| 199 | .Fn BIO_set_conn_ip | 185 | .Fn BIO_set_conn_ip |
| 200 | sets the IP address to | 186 | sets the IP address to |
