diff options
Diffstat (limited to 'src/lib/libcrypto/bio/b_sock.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index db8a30538c..0cc570b66f 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.62 2016/12/20 23:14:37 beck Exp $ */ | 1 | /* $OpenBSD: b_sock.c,v 1.63 2017/01/29 17:49:22 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 | * |
@@ -89,13 +89,12 @@ BIO_get_host_ip(const char *str, unsigned char *ip) | |||
89 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); | 89 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); |
90 | he = BIO_gethostbyname(str); | 90 | he = BIO_gethostbyname(str); |
91 | if (he == NULL) { | 91 | if (he == NULL) { |
92 | BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_BAD_HOSTNAME_LOOKUP); | 92 | BIOerror(BIO_R_BAD_HOSTNAME_LOOKUP); |
93 | goto err; | 93 | goto err; |
94 | } | 94 | } |
95 | 95 | ||
96 | if (he->h_addrtype != AF_INET) { | 96 | if (he->h_addrtype != AF_INET) { |
97 | BIOerr(BIO_F_BIO_GET_HOST_IP, | 97 | BIOerror(BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); |
98 | BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); | ||
99 | goto err; | 98 | goto err; |
100 | } | 99 | } |
101 | for (i = 0; i < 4; i++) | 100 | for (i = 0; i < 4; i++) |
@@ -123,7 +122,7 @@ BIO_get_port(const char *str, unsigned short *port_ptr) | |||
123 | int error; | 122 | int error; |
124 | 123 | ||
125 | if (str == NULL) { | 124 | if (str == NULL) { |
126 | BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_SPECIFIED); | 125 | BIOerror(BIO_R_NO_PORT_SPECIFIED); |
127 | return (0); | 126 | return (0); |
128 | } | 127 | } |
129 | 128 | ||
@@ -162,7 +161,7 @@ BIO_socket_ioctl(int fd, long type, void *arg) | |||
162 | 161 | ||
163 | ret = ioctl(fd, type, arg); | 162 | ret = ioctl(fd, type, arg); |
164 | if (ret < 0) | 163 | if (ret < 0) |
165 | SYSerr(SYS_F_IOCTLSOCKET, errno); | 164 | SYSerror(errno); |
166 | return (ret); | 165 | return (ret); |
167 | } | 166 | } |
168 | 167 | ||
@@ -258,10 +257,9 @@ BIO_get_accept_socket(char *host, int bind_mode) | |||
258 | again: | 257 | again: |
259 | s = socket(server.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); | 258 | s = socket(server.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); |
260 | if (s == -1) { | 259 | if (s == -1) { |
261 | SYSerr(SYS_F_SOCKET, errno); | 260 | SYSerror(errno); |
262 | ERR_asprintf_error_data("port='%s'", host); | 261 | ERR_asprintf_error_data("port='%s'", host); |
263 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, | 262 | BIOerror(BIO_R_UNABLE_TO_CREATE_SOCKET); |
264 | BIO_R_UNABLE_TO_CREATE_SOCKET); | ||
265 | goto err; | 263 | goto err; |
266 | } | 264 | } |
267 | 265 | ||
@@ -301,17 +299,15 @@ again: | |||
301 | } | 299 | } |
302 | /* else error */ | 300 | /* else error */ |
303 | } | 301 | } |
304 | SYSerr(SYS_F_BIND, err_num); | 302 | SYSerror(err_num); |
305 | ERR_asprintf_error_data("port='%s'", host); | 303 | ERR_asprintf_error_data("port='%s'", host); |
306 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, | 304 | BIOerror(BIO_R_UNABLE_TO_BIND_SOCKET); |
307 | BIO_R_UNABLE_TO_BIND_SOCKET); | ||
308 | goto err; | 305 | goto err; |
309 | } | 306 | } |
310 | if (listen(s, SOMAXCONN) == -1) { | 307 | if (listen(s, SOMAXCONN) == -1) { |
311 | SYSerr(SYS_F_BIND, errno); | 308 | SYSerror(errno); |
312 | ERR_asprintf_error_data("port='%s'", host); | 309 | ERR_asprintf_error_data("port='%s'", host); |
313 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, | 310 | BIOerror(BIO_R_UNABLE_TO_LISTEN_SOCKET); |
314 | BIO_R_UNABLE_TO_LISTEN_SOCKET); | ||
315 | goto err; | 311 | goto err; |
316 | } | 312 | } |
317 | ret = 1; | 313 | ret = 1; |
@@ -347,8 +343,8 @@ BIO_accept(int sock, char **addr) | |||
347 | if (ret == -1) { | 343 | if (ret == -1) { |
348 | if (BIO_sock_should_retry(ret)) | 344 | if (BIO_sock_should_retry(ret)) |
349 | return -2; | 345 | return -2; |
350 | SYSerr(SYS_F_ACCEPT, errno); | 346 | SYSerror(errno); |
351 | BIOerr(BIO_F_BIO_ACCEPT, BIO_R_ACCEPT_ERROR); | 347 | BIOerror(BIO_R_ACCEPT_ERROR); |
352 | goto end; | 348 | goto end; |
353 | } | 349 | } |
354 | 350 | ||
@@ -371,7 +367,7 @@ BIO_accept(int sock, char **addr) | |||
371 | ret = -1; | 367 | ret = -1; |
372 | free(p); | 368 | free(p); |
373 | *addr = NULL; | 369 | *addr = NULL; |
374 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | 370 | BIOerror(ERR_R_MALLOC_FAILURE); |
375 | goto end; | 371 | goto end; |
376 | } | 372 | } |
377 | p = tmp; | 373 | p = tmp; |
@@ -387,7 +383,7 @@ BIO_accept(int sock, char **addr) | |||
387 | if ((p = malloc(24)) == NULL) { | 383 | if ((p = malloc(24)) == NULL) { |
388 | close(ret); | 384 | close(ret); |
389 | ret = -1; | 385 | ret = -1; |
390 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | 386 | BIOerror(ERR_R_MALLOC_FAILURE); |
391 | goto end; | 387 | goto end; |
392 | } | 388 | } |
393 | *addr = p; | 389 | *addr = p; |