# 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
int BIO_sock_error(int sock)
{
int j = 0, i;
- socklen_t size = 0;
+ socklen_t size = sizeof(j);
/*
* Note: under Windows the third parameter is of type (char *) whereas
*/
i = getsockopt(sock, SOL_SOCKET, SO_ERROR, (void *)&j, &size);
if (i < 0)
- return (1);
+ return (get_last_socket_error());
else
return (j);
}
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);
}
-void BIO_sock_cleanup(void)
+void bio_sock_cleanup_int(void)
{
# ifdef OPENSSL_SYS_WINDOWS
if (wsa_init_done) {
wsa_init_done = 0;
WSACleanup();
}
-# elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)
- if (wsa_init_done) {
- wsa_init_done = 0;
- WSACleanup();
- }
# endif
}
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;
}
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, ":");
}
end:
- BIO_ADDR_free(res);
return ret;
}
# endif