Fix return value checking for BIO_sock_init
authorPaul Yang <paulyang.inf@gmail.com>
Sun, 25 Jun 2017 17:09:46 +0000 (01:09 +0800)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 26 Jun 2017 13:19:12 +0000 (15:19 +0200)
BIO_sock_init returns '-1' on error, not '0', so it's needed to check
explicitly istead of using '!'.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/3766)

apps/s_socket.c
test/handshake_helper.c

index 1c5c13742cba1a142539af036452df917c18b1d6..b2bf244f23e38d7af59bc7a06697b43f34adbbb7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -62,7 +62,7 @@ int init_client(int *sock, const char *host, const char *port,
     const BIO_ADDRINFO *ai = NULL;
     int ret;
 
-    if (!BIO_sock_init())
+    if (BIO_sock_init() != 1)
         return 0;
 
     ret = BIO_lookup_ex(host, port, BIO_LOOKUP_CLIENT, family, type, protocol,
@@ -161,7 +161,7 @@ int do_server(int *accept_sock, const char *host, const char *port,
     BIO_ADDRINFO *res = NULL;
     int ret = 0;
 
-    if (!BIO_sock_init())
+    if (BIO_sock_init() != 1)
         return 0;
 
     if (!BIO_lookup_ex(host, port, BIO_LOOKUP_SERVER, family, type, protocol,
index 509a8f6ede357e64683b8f382a609f79cd91c389..1192227a42a33d62a8f5e818a521ce238880d59d 100644 (file)
@@ -1135,7 +1135,7 @@ static int create_sctp_socks(int *ssock, int *csock)
     int ret = 0;
     int family = 0;
 
-    if (!BIO_sock_init())
+    if (BIO_sock_init() != 1)
         return 0;
 
     /*