Make BIO opaque
[openssl.git] / crypto / bio / b_sock.c
index 4ae08d2d8426cbbafc66ed4029aea95db268c782..046de991900c8d15d4199566074bf6eb72e21739 100644 (file)
@@ -72,7 +72,7 @@ NETDB_DEFINE_CONTEXT
 # else
 #  define MAX_LISTEN  32
 # endif
-# if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK))
+# if defined(OPENSSL_SYS_WINDOWS)
 static int wsa_init_done = 0;
 # endif
 
@@ -202,23 +202,6 @@ int BIO_sock_init(void)
         return (-1);
 # endif
 
-# if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)
-    WORD wVerReq;
-    WSADATA wsaData;
-    int err;
-
-    if (!wsa_init_done) {
-        wsa_init_done = 1;
-        wVerReq = MAKEWORD(2, 0);
-        err = WSAStartup(wVerReq, &wsaData);
-        if (err != 0) {
-            SYSerr(SYS_F_WSASTARTUP, err);
-            BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);
-            return (-1);
-        }
-    }
-# endif
-
     return (1);
 }
 
@@ -229,11 +212,6 @@ void BIO_sock_cleanup(void)
         wsa_init_done = 0;
         WSACleanup();
     }
-# elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)
-    if (wsa_init_done) {
-        wsa_init_done = 0;
-        WSACleanup();
-    }
 # endif
 }
 
@@ -316,16 +294,10 @@ int BIO_get_accept_socket(char *host, int bind_mode)
 
 int BIO_accept(int sock, char **ip_port)
 {
-    BIO_ADDR *res = BIO_ADDR_new();
+    BIO_ADDR res;
     int ret = -1;
 
-    if (res == NULL) {
-        BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
-        return ret;
-    }
-
-    ret = BIO_accept_ex(sock, res, 0);
-
+    ret = BIO_accept_ex(sock, &res, 0);
     if (ret == (int)INVALID_SOCKET) {
         if (BIO_sock_should_retry(ret)) {
             ret = -2;
@@ -337,8 +309,8 @@ int BIO_accept(int sock, char **ip_port)
     }
 
     if (ip_port != NULL) {
-        char *host = BIO_ADDR_hostname_string(res, 1);
-        char *port = BIO_ADDR_service_string(res, 1);
+        char *host = BIO_ADDR_hostname_string(&res, 1);
+        char *port = BIO_ADDR_service_string(&res, 1);
         *ip_port = OPENSSL_zalloc(strlen(host) + strlen(port) + 2);
         strcpy(*ip_port, host);
         strcat(*ip_port, ":");
@@ -348,7 +320,6 @@ int BIO_accept(int sock, char **ip_port)
     }
 
  end:
-    BIO_ADDR_free(res);
     return ret;
 }
 # endif
@@ -432,7 +403,7 @@ int BIO_sock_info(int sock,
                 BIOerr(BIO_F_BIO_SOCK_INFO, BIO_R_GETSOCKNAME_ERROR);
                 return 0;
             }
-            if (addr_len > sizeof(*info->addr)) {
+            if ((size_t)addr_len > sizeof(*info->addr)) {
                 BIOerr(BIO_F_BIO_SOCK_INFO, BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS);
                 return 0;
             }