summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcrypto/bio/b_sock.c42
-rw-r--r--lib/libcrypto/bio/bss_acpt.c18
-rw-r--r--lib/libcrypto/bio/bss_conn.c24
-rw-r--r--lib/libcrypto/bio/bss_dgram.c26
-rw-r--r--lib/libcrypto/bio/bss_fd.c6
-rw-r--r--lib/libcrypto/bio/bss_file.c6
-rw-r--r--lib/libcrypto/bio/bss_sock.c10
-rw-r--r--lib/libcrypto/err/err.c2
8 files changed, 67 insertions, 67 deletions
diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c
index 41f958be710..779acbaaf5a 100644
--- a/lib/libcrypto/bio/b_sock.c
+++ b/lib/libcrypto/bio/b_sock.c
@@ -221,7 +221,7 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
#endif
else
{
- SYSerr(SYS_F_GETSERVBYNAME,get_last_socket_error());
+ SYSerr(SYS_F_GETSERVBYNAME,errno);
ERR_add_error_data(3,"service='",str,"'");
return(0);
}
@@ -549,7 +549,7 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
int i;
#ifdef __DJGPP__
- i=ioctlsocket(fd,type,(char *)arg);
+ i=ioctl(fd,type,(char *)arg);
#else
# if defined(OPENSSL_SYS_VMS)
/* 2011-02-18 SMS.
@@ -574,10 +574,10 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
# define ARG arg
# endif /* defined(OPENSSL_SYS_VMS) [else] */
- i=ioctlsocket(fd,type,ARG);
+ i=ioctl(fd,type,ARG);
#endif /* __DJGPP__ */
if (i < 0)
- SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
+ SYSerr(SYS_F_IOCTLSOCKET,errno);
return(i);
}
#endif /* __VMS_VER */
@@ -629,7 +629,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
struct sockaddr_in6 sa_in6;
#endif
} server,client;
- int s=INVALID_SOCKET,cs,addrlen;
+ int s=-1,cs,addrlen;
unsigned char ip[4];
unsigned short port;
char *str=NULL,*e;
@@ -637,9 +637,9 @@ int BIO_get_accept_socket(char *host, int bind_mode)
unsigned long l;
int err_num;
- if (BIO_sock_init() != 1) return(INVALID_SOCKET);
+ if (BIO_sock_init() != 1) return(-1);
- if ((str=BUF_strdup(host)) == NULL) return(INVALID_SOCKET);
+ if ((str=BUF_strdup(host)) == NULL) return(-1);
h=p=NULL;
h=str;
@@ -736,9 +736,9 @@ int BIO_get_accept_socket(char *host, int bind_mode)
again:
s=socket(server.sa.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
- if (s == INVALID_SOCKET)
+ if (s == -1)
{
- SYSerr(SYS_F_SOCKET,get_last_socket_error());
+ SYSerr(SYS_F_SOCKET,errno);
ERR_add_error_data(3,"port='",host,"'");
BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_CREATE_SOCKET);
goto err;
@@ -756,7 +756,7 @@ again:
if (bind(s,&server.sa,addrlen) == -1)
{
#ifdef SO_REUSEADDR
- err_num=get_last_socket_error();
+ err_num=errno;
if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) &&
#ifdef OPENSSL_SYS_WINDOWS
/* Some versions of Windows define EADDRINUSE to
@@ -785,15 +785,15 @@ again:
else goto err;
}
cs=socket(client.sa.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
- if (cs != INVALID_SOCKET)
+ if (cs != -1)
{
int ii;
ii=connect(cs,&client.sa,addrlen);
- closesocket(cs);
- if (ii == INVALID_SOCKET)
+ close(cs);
+ if (ii == -1)
{
bind_mode=BIO_BIND_REUSEADDR;
- closesocket(s);
+ close(s);
goto again;
}
/* else error */
@@ -808,7 +808,7 @@ again:
}
if (listen(s,MAX_LISTEN) == -1)
{
- SYSerr(SYS_F_BIND,get_last_socket_error());
+ SYSerr(SYS_F_BIND,errno);
ERR_add_error_data(3,"port='",host,"'");
BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_LISTEN_SOCKET);
goto err;
@@ -816,17 +816,17 @@ again:
ret=1;
err:
if (str != NULL) OPENSSL_free(str);
- if ((ret == 0) && (s != INVALID_SOCKET))
+ if ((ret == 0) && (s != -1))
{
- closesocket(s);
- s= INVALID_SOCKET;
+ close(s);
+ s= -1;
}
return(s);
}
int BIO_accept(int sock, char **addr)
{
- int ret=INVALID_SOCKET;
+ int ret=-1;
unsigned long l;
unsigned short port;
char *p;
@@ -873,10 +873,10 @@ int BIO_accept(int sock, char **addr)
sa.len.i = (int)sa.len.s;
/* use sa.len.i from this point */
}
- if (ret == INVALID_SOCKET)
+ if (ret == -1)
{
if(BIO_sock_should_retry(ret)) return -2;
- SYSerr(SYS_F_ACCEPT,get_last_socket_error());
+ SYSerr(SYS_F_ACCEPT,errno);
BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR);
goto end;
}
diff --git a/lib/libcrypto/bio/bss_acpt.c b/lib/libcrypto/bio/bss_acpt.c
index 5d49e1a72bc..5507a53a2fa 100644
--- a/lib/libcrypto/bio/bss_acpt.c
+++ b/lib/libcrypto/bio/bss_acpt.c
@@ -131,7 +131,7 @@ static int acpt_new(BIO *bi)
BIO_ACCEPT *ba;
bi->init=0;
- bi->num=INVALID_SOCKET;
+ bi->num=-1;
bi->flags=0;
if ((ba=BIO_ACCEPT_new()) == NULL)
return(0);
@@ -149,7 +149,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void)
return(NULL);
memset(ret,0,sizeof(BIO_ACCEPT));
- ret->accept_sock=INVALID_SOCKET;
+ ret->accept_sock=-1;
ret->bind_mode=BIO_BIND_NORMAL;
return(ret);
}
@@ -170,12 +170,12 @@ static void acpt_close_socket(BIO *bio)
BIO_ACCEPT *c;
c=(BIO_ACCEPT *)bio->ptr;
- if (c->accept_sock != INVALID_SOCKET)
+ if (c->accept_sock != -1)
{
shutdown(c->accept_sock,2);
- closesocket(c->accept_sock);
- c->accept_sock=INVALID_SOCKET;
- bio->num=INVALID_SOCKET;
+ close(c->accept_sock);
+ c->accept_sock=-1;
+ bio->num=-1;
}
}
@@ -213,14 +213,14 @@ again:
return(-1);
}
s=BIO_get_accept_socket(c->param_addr,c->bind_mode);
- if (s == INVALID_SOCKET)
+ if (s == -1)
return(-1);
if (c->accept_nbio)
{
if (!BIO_socket_nbio(s,1))
{
- closesocket(s);
+ close(s);
BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET);
return(-1);
}
@@ -282,7 +282,7 @@ err:
if (bio != NULL)
BIO_free(bio);
else if (s >= 0)
- closesocket(s);
+ close(s);
return(0);
/* break; */
case ACPT_S_OK:
diff --git a/lib/libcrypto/bio/bss_conn.c b/lib/libcrypto/bio/bss_conn.c
index c14727855b2..bdf540030c8 100644
--- a/lib/libcrypto/bio/bss_conn.c
+++ b/lib/libcrypto/bio/bss_conn.c
@@ -210,9 +210,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
c->state=BIO_CONN_S_CREATE_SOCKET;
ret=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
- if (ret == INVALID_SOCKET)
+ if (ret == -1)
{
- SYSerr(SYS_F_SOCKET,get_last_socket_error());
+ SYSerr(SYS_F_SOCKET,errno);
ERR_add_error_data(4,"host=",c->param_hostname,
":",c->param_port);
BIOerr(BIO_F_CONN_STATE,BIO_R_UNABLE_TO_CREATE_SOCKET);
@@ -241,7 +241,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
if (i < 0)
{
- SYSerr(SYS_F_SOCKET,get_last_socket_error());
+ SYSerr(SYS_F_SOCKET,errno);
ERR_add_error_data(4,"host=",c->param_hostname,
":",c->param_port);
BIOerr(BIO_F_CONN_STATE,BIO_R_KEEPALIVE);
@@ -266,7 +266,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
}
else
{
- SYSerr(SYS_F_CONNECT,get_last_socket_error());
+ SYSerr(SYS_F_CONNECT,errno);
ERR_add_error_data(4,"host=",
c->param_hostname,
":",c->param_port);
@@ -358,7 +358,7 @@ BIO_METHOD *BIO_s_connect(void)
static int conn_new(BIO *bi)
{
bi->init=0;
- bi->num=INVALID_SOCKET;
+ bi->num=-1;
bi->flags=0;
if ((bi->ptr=(char *)BIO_CONNECT_new()) == NULL)
return(0);
@@ -371,13 +371,13 @@ static void conn_close_socket(BIO *bio)
BIO_CONNECT *c;
c=(BIO_CONNECT *)bio->ptr;
- if (bio->num != INVALID_SOCKET)
+ if (bio->num != -1)
{
/* Only do a shutdown if things were established */
if (c->state == BIO_CONN_S_OK)
shutdown(bio->num,2);
- closesocket(bio->num);
- bio->num=INVALID_SOCKET;
+ close(bio->num);
+ bio->num=-1;
}
}
@@ -414,8 +414,8 @@ static int conn_read(BIO *b, char *out, int outl)
if (out != NULL)
{
- clear_socket_error();
- ret=readsocket(b->num,out,outl);
+ errno = 0;
+ ret=read(b->num,out,outl);
BIO_clear_retry_flags(b);
if (ret <= 0)
{
@@ -438,8 +438,8 @@ static int conn_write(BIO *b, const char *in, int inl)
if (ret <= 0) return(ret);
}
- clear_socket_error();
- ret=writesocket(b->num,in,inl);
+ errno = 0;
+ ret=write(b->num,in,inl);
BIO_clear_retry_flags(b);
if (ret <= 0)
{
diff --git a/lib/libcrypto/bio/bss_dgram.c b/lib/libcrypto/bio/bss_dgram.c
index f39f94f7fe4..d09c0fc33e3 100644
--- a/lib/libcrypto/bio/bss_dgram.c
+++ b/lib/libcrypto/bio/bss_dgram.c
@@ -383,7 +383,7 @@ static int dgram_read(BIO *b, char *out, int outl)
if (out != NULL)
{
- clear_socket_error();
+ errno = 0;
memset(&sa.peer, 0x00, sizeof(sa.peer));
dgram_adjust_rcv_timeout(b);
ret=recvfrom(b->num,out,outl,0,&sa.peer.sa,(void *)&sa.len);
@@ -402,7 +402,7 @@ static int dgram_read(BIO *b, char *out, int outl)
if (BIO_dgram_should_retry(ret))
{
BIO_set_retry_read(b);
- data->_errno = get_last_socket_error();
+ data->_errno = errno;
}
}
@@ -415,10 +415,10 @@ static int dgram_write(BIO *b, const char *in, int inl)
{
int ret;
bio_dgram_data *data = (bio_dgram_data *)b->ptr;
- clear_socket_error();
+ errno = 0;
if ( data->connected )
- ret=writesocket(b->num,in,inl);
+ ret=write(b->num,in,inl);
else
{
int peerlen = sizeof(data->peer);
@@ -442,7 +442,7 @@ static int dgram_write(BIO *b, const char *in, int inl)
if (BIO_dgram_should_retry(ret))
{
BIO_set_retry_write(b);
- data->_errno = get_last_socket_error();
+ data->_errno = errno;
#if 0 /* higher layers are responsible for querying MTU, if necessary */
if ( data->_errno == EMSGSIZE)
@@ -1018,7 +1018,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
if (out != NULL)
{
- clear_socket_error();
+ errno = 0;
do
{
@@ -1180,7 +1180,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
if (BIO_dgram_should_retry(ret))
{
BIO_set_retry_read(b);
- data->_errno = get_last_socket_error();
+ data->_errno = errno;
}
}
@@ -1238,7 +1238,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
struct sctp_sndrcvinfo *sndrcvinfo;
#endif
- clear_socket_error();
+ errno = 0;
/* If we're send anything else than application data,
* disable all user parameters and flags.
@@ -1321,7 +1321,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
if (BIO_dgram_should_retry(ret))
{
BIO_set_retry_write(b);
- data->_errno = get_last_socket_error();
+ data->_errno = errno;
}
}
return(ret);
@@ -1596,7 +1596,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b)
n = recvmsg(b->num, &msg, MSG_PEEK);
if (n <= 0)
{
- if ((n < 0) && (get_last_socket_error() != EAGAIN) && (get_last_socket_error() != EWOULDBLOCK))
+ if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK))
return -1;
else
return 0;
@@ -1619,7 +1619,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b)
n = recvmsg(b->num, &msg, 0);
if (n <= 0)
{
- if ((n < 0) && (get_last_socket_error() != EAGAIN) && (get_last_socket_error() != EWOULDBLOCK))
+ if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK))
return -1;
else
return is_dry;
@@ -1686,7 +1686,7 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b)
if (n <= 0)
{
- if ((n < 0) && (get_last_socket_error() != EAGAIN) && (get_last_socket_error() != EWOULDBLOCK))
+ if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK))
return -1;
else
return is_dry;
@@ -1773,7 +1773,7 @@ static int BIO_dgram_should_retry(int i)
if ((i == 0) || (i == -1))
{
- err=get_last_socket_error();
+ err=errno;
#if defined(OPENSSL_SYS_WINDOWS)
/* If the socket return value (i) is -1
diff --git a/lib/libcrypto/bio/bss_fd.c b/lib/libcrypto/bio/bss_fd.c
index d1bf85aae17..ab18a56310d 100644
--- a/lib/libcrypto/bio/bss_fd.c
+++ b/lib/libcrypto/bio/bss_fd.c
@@ -147,7 +147,7 @@ static int fd_read(BIO *b, char *out,int outl)
if (out != NULL)
{
- clear_sys_error();
+ errno = 0;
ret=UP_read(b->num,out,outl);
BIO_clear_retry_flags(b);
if (ret <= 0)
@@ -162,7 +162,7 @@ static int fd_read(BIO *b, char *out,int outl)
static int fd_write(BIO *b, const char *in, int inl)
{
int ret;
- clear_sys_error();
+ errno = 0;
ret=UP_write(b->num,in,inl);
BIO_clear_retry_flags(b);
if (ret <= 0)
@@ -257,7 +257,7 @@ int BIO_fd_should_retry(int i)
if ((i == 0) || (i == -1))
{
- err=get_last_sys_error();
+ err=errno;
#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
if ((i == -1) && (err == 0))
diff --git a/lib/libcrypto/bio/bss_file.c b/lib/libcrypto/bio/bss_file.c
index 4a4e747bc71..638572ab7fd 100644
--- a/lib/libcrypto/bio/bss_file.c
+++ b/lib/libcrypto/bio/bss_file.c
@@ -166,7 +166,7 @@ BIO *BIO_new_file(const char *filename, const char *mode)
#endif
if (file == NULL)
{
- SYSerr(SYS_F_FOPEN,get_last_sys_error());
+ SYSerr(SYS_F_FOPEN, errno);
ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
if (errno == ENOENT)
BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
@@ -242,7 +242,7 @@ static int file_read(BIO *b, char *out, int outl)
ret=fread(out,1,(int)outl,(FILE *)b->ptr);
if(ret == 0 && (b->flags&BIO_FLAGS_UPLINK)?UP_ferror((FILE *)b->ptr):ferror((FILE *)b->ptr))
{
- SYSerr(SYS_F_FREAD,get_last_sys_error());
+ SYSerr(SYS_F_FREAD, errno);
BIOerr(BIO_F_FILE_READ,ERR_R_SYS_LIB);
ret=-1;
}
@@ -395,7 +395,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
fp=fopen(ptr,p);
if (fp == NULL)
{
- SYSerr(SYS_F_FOPEN,get_last_sys_error());
+ SYSerr(SYS_F_FOPEN, errno);
ERR_add_error_data(5,"fopen('",ptr,"','",p,"')");
BIOerr(BIO_F_FILE_CTRL,ERR_R_SYS_LIB);
ret=0;
diff --git a/lib/libcrypto/bio/bss_sock.c b/lib/libcrypto/bio/bss_sock.c
index 3df31938c18..07e52ec4005 100644
--- a/lib/libcrypto/bio/bss_sock.c
+++ b/lib/libcrypto/bio/bss_sock.c
@@ -138,8 +138,8 @@ static int sock_read(BIO *b, char *out, int outl)
if (out != NULL)
{
- clear_socket_error();
- ret=readsocket(b->num,out,outl);
+ errno = 0;
+ ret=read(b->num,out,outl);
BIO_clear_retry_flags(b);
if (ret <= 0)
{
@@ -154,8 +154,8 @@ static int sock_write(BIO *b, const char *in, int inl)
{
int ret;
- clear_socket_error();
- ret=writesocket(b->num,in,inl);
+ errno = 0;
+ ret=write(b->num,in,inl);
BIO_clear_retry_flags(b);
if (ret <= 0)
{
@@ -220,7 +220,7 @@ int BIO_sock_should_retry(int i)
if ((i == 0) || (i == -1))
{
- err=get_last_socket_error();
+ err=errno;
#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
if ((i == -1) && (err == 0))
diff --git a/lib/libcrypto/err/err.c b/lib/libcrypto/err/err.c
index fcdb244008f..0251248bafd 100644
--- a/lib/libcrypto/err/err.c
+++ b/lib/libcrypto/err/err.c
@@ -165,7 +165,7 @@ static ERR_STRING_DATA ERR_str_functs[]=
{ERR_PACK(0,SYS_F_CONNECT,0), "connect"},
{ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
{ERR_PACK(0,SYS_F_SOCKET,0), "socket"},
- {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
+ {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctl"},
{ERR_PACK(0,SYS_F_BIND,0), "bind"},
{ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
{ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},