libreSSL/patches/win_bio_sock_init.diff
Brent Cook f7e4e4a266 initialize winsock earlier in openssl(1)
This allows commands like ocsp to work properly since we no longer
initialize Winsock as a side-effect of doing a BIO_gethostbyname.
2015-03-08 22:02:54 -05:00

45 lines
1.3 KiB
Diff

diff --git a/src/usr.bin/openssl/openssl.c b/src/usr.bin/openssl/openssl.c
index e7dd11c..cfd4593 100644
--- a/src/usr.bin/openssl/openssl.c
+++ b/src/usr.bin/openssl/openssl.c
@@ -253,6 +253,11 @@ main(int argc, char **argv)
arg.data = NULL;
arg.count = 0;
+ if (BIO_sock_init() != 1) {
+ fprintf(stderr, "BIO_sock_init failed\n");
+ exit(1);
+ }
+
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
if (bio_err == NULL) {
fprintf(stderr, "openssl: failed to initialise bio_err\n");
diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c
index 3b96b1a..2ce31eb 100644
--- a/src/usr.bin/openssl/s_socket.c
+++ b/src/usr.bin/openssl/s_socket.c
@@ -85,11 +85,6 @@ init_client(int *sock, char *host, char *port, int type, int af)
struct addrinfo hints, *ai_top, *ai;
int i, s;
- if (BIO_sock_init() != 1) {
- BIO_printf(bio_err, "BIO_sock_init failed\n");
- return (0);
- }
-
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = type;
@@ -181,11 +176,6 @@ init_server_long(int *sock, int port, char *ip, int type)
struct sockaddr_in server;
int s = -1;
- if (BIO_sock_init() != 1) {
- BIO_printf(bio_err, "BIO_sock_init failed\n");
- return (0);
- }
-
memset((char *) &server, 0, sizeof(server));
server.sin_family = AF_INET;
server.sin_port = htons((unsigned short) port);