diff options
| author | beck <> | 2016-12-20 23:14:37 +0000 |
|---|---|---|
| committer | beck <> | 2016-12-20 23:14:37 +0000 |
| commit | 718ab6235df17d368ba0344f7397cb2cb7e569b2 (patch) | |
| tree | 5933ca58ab406c9ea7ae2d23761b6e6a0d278eeb /src/lib/libcrypto/bio | |
| parent | 34e67f293c761ea1fdc5fbb6bcd1a52efa2c1a9d (diff) | |
| download | openbsd-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/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 51 |
1 files changed, 7 insertions, 44 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 | ||
