summaryrefslogtreecommitdiffstats
path: root/crypto/bio
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2019-07-31 21:24:20 +0200
committerRichard Levitte <levitte@openssl.org>2019-08-02 11:41:54 +0200
commitff988500c2f39ae61b2836167b6e0e7b2021220c (patch)
treeead6acf74e2cf8c8be430e02f78dddcf8281b0cc /crypto/bio
parentUse NULL as parameter when pointer can only be NULL. (diff)
downloadopenssl-ff988500c2f39ae61b2836167b6e0e7b2021220c.tar.xz
openssl-ff988500c2f39ae61b2836167b6e0e7b2021220c.zip
Replace FUNCerr with ERR_raise_data
Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9496)
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/b_addr.c18
-rw-r--r--crypto/bio/b_sock.c18
-rw-r--r--crypto/bio/b_sock2.c36
-rw-r--r--crypto/bio/bss_acpt.c7
-rw-r--r--crypto/bio/bss_conn.c21
-rw-r--r--crypto/bio/bss_file.c17
6 files changed, 70 insertions, 47 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index e2354e3421..47366332ac 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -207,7 +207,8 @@ static int addr_strings(const BIO_ADDR *ap, int numeric,
flags)) != 0) {
# ifdef EAI_SYSTEM
if (ret == EAI_SYSTEM) {
- FUNCerr("getnameinfo", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling getnameinfo()");
BIOerr(BIO_F_ADDR_STRINGS, ERR_R_SYS_LIB);
} else
# endif
@@ -700,7 +701,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
# ifdef EAI_SYSTEM
case EAI_SYSTEM:
- FUNCerr("getaddrinfo", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling getaddrinfo()");
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
break;
# endif
@@ -804,12 +806,15 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
*/
# if defined(OPENSSL_SYS_VXWORKS)
/* h_errno doesn't exist on VxWorks */
- FUNCerr("gethostbyname", 1000 );
+ ERR_raise_data(ERR_LIB_SYS, 1000,
+ "calling gethostbyname()");
# else
- FUNCerr("gethostbyname", 1000 + h_errno);
+ ERR_raise_data(ERR_LIB_SYS, 1000 + h_errno,
+ "calling gethostbyname()");
# endif
#else
- FUNCerr("gethostbyname", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling gethostbyname()");
#endif
ret = 0;
goto err;
@@ -855,7 +860,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
se = getservbyname(service, proto);
if (se == NULL) {
- FUNCerr("getservbyname", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling getservbyname()");
goto err;
}
} else {
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index 46a2ff7dbc..1747cce658 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -129,7 +129,8 @@ int BIO_sock_init(void)
* probed at run-time with DSO_global_lookup.
*/
if (WSAStartup(0x0202, &wsa_state) != 0) {
- FUNCerr("wsastartup", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling wsastartup()");
BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);
return -1;
}
@@ -189,7 +190,8 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
i = ioctlsocket(fd, type, ARG);
# endif /* __DJGPP__ */
if (i < 0)
- FUNCerr("ioctlsocket", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling ioctlsocket()");
return i;
}
@@ -240,7 +242,8 @@ int BIO_accept(int sock, char **ip_port)
ret = -2;
goto end;
}
- FUNCerr("accept", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling accept()");
BIOerr(BIO_F_BIO_ACCEPT, BIO_R_ACCEPT_ERROR);
goto end;
}
@@ -305,7 +308,8 @@ int BIO_socket_nbio(int s, int mode)
l = fcntl(s, F_GETFL, 0);
if (l == -1) {
- FUNCerr("fcntl", get_last_sys_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fcntl()");
ret = -1;
} else {
# if defined(O_NONBLOCK)
@@ -323,7 +327,8 @@ int BIO_socket_nbio(int s, int mode)
ret = fcntl(s, F_SETFL, l);
if (ret < 0) {
- FUNCerr("fcntl", get_last_sys_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fcntl()");
}
}
# else
@@ -346,7 +351,8 @@ int BIO_sock_info(int sock,
ret = getsockname(sock, BIO_ADDR_sockaddr_noconst(info->addr),
&addr_len);
if (ret == -1) {
- FUNCerr("getsockname", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling getsockname()");
BIOerr(BIO_F_BIO_SOCK_INFO, BIO_R_GETSOCKNAME_ERROR);
return 0;
}
diff --git a/crypto/bio/b_sock2.c b/crypto/bio/b_sock2.c
index ee269513c6..abfd704772 100644
--- a/crypto/bio/b_sock2.c
+++ b/crypto/bio/b_sock2.c
@@ -46,7 +46,8 @@ int BIO_socket(int domain, int socktype, int protocol, int options)
sock = socket(domain, socktype, protocol);
if (sock == -1) {
- FUNCerr("socket", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling socket()");
BIOerr(BIO_F_BIO_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);
return INVALID_SOCKET;
}
@@ -89,7 +90,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
if (options & BIO_SOCK_KEEPALIVE) {
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_KEEPALIVE);
return 0;
}
@@ -98,7 +100,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
if (options & BIO_SOCK_NODELAY) {
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_NODELAY);
return 0;
}
@@ -107,7 +110,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
if (connect(sock, BIO_ADDR_sockaddr(addr),
BIO_ADDR_sockaddr_size(addr)) == -1) {
if (!BIO_sock_should_retry(-1)) {
- FUNCerr("connect", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling connect()");
BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
}
return 0;
@@ -150,7 +154,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
if (options & BIO_SOCK_REUSEADDR) {
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_REUSEADDR);
return 0;
}
@@ -158,7 +163,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
# endif
if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
- FUNCerr("bind", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling bind()");
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_BIND_SOCKET);
return 0;
}
@@ -217,7 +223,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
if (getsockopt(sock, SOL_SOCKET, SO_TYPE,
(void *)&socktype, &socktype_len) != 0
|| socktype_len != sizeof(socktype)) {
- FUNCerr("getsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling getsockopt()");
BIOerr(BIO_F_BIO_LISTEN, BIO_R_GETTING_SOCKTYPE);
return 0;
}
@@ -228,7 +235,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
if (options & BIO_SOCK_KEEPALIVE) {
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_KEEPALIVE);
return 0;
}
@@ -237,7 +245,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
if (options & BIO_SOCK_NODELAY) {
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_NODELAY);
return 0;
}
@@ -252,7 +261,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
(const void *)&on, sizeof(on)) != 0) {
- FUNCerr("setsockopt", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling setsockopt()");
BIOerr(BIO_F_BIO_LISTEN, BIO_R_LISTEN_V6_ONLY);
return 0;
}
@@ -263,7 +273,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
return 0;
if (socktype != SOCK_DGRAM && listen(sock, MAX_LISTEN) == -1) {
- FUNCerr("listen", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling listen()");
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_LISTEN_SOCKET);
return 0;
}
@@ -290,7 +301,8 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
BIO_ADDR_sockaddr_noconst(addr), &len);
if (accepted_sock == -1) {
if (!BIO_sock_should_retry(accepted_sock)) {
- FUNCerr("accept", get_last_socket_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling accept()");
BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
}
return INVALID_SOCKET;
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index c47b75095a..830c1b9679 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -226,10 +226,9 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
BIO_ADDRINFO_socktype(c->addr_iter),
BIO_ADDRINFO_protocol(c->addr_iter), 0);
if (ret == (int)INVALID_SOCKET) {
- FUNCerr("socket", get_last_socket_error());
- ERR_add_error_data(4,
- "hostname=", c->param_addr,
- " service=", c->param_serv);
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling socket(%s, %s)",
+ c->param_addr, c->param_serv);
BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
goto exit_loop;
}
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index 330c64f818..56fb392c61 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -138,10 +138,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
BIO_ADDRINFO_socktype(c->addr_iter),
BIO_ADDRINFO_protocol(c->addr_iter), 0);
if (ret == (int)INVALID_SOCKET) {
- FUNCerr("socket", get_last_socket_error());
- ERR_add_error_data(4,
- "hostname=", c->param_hostname,
- " service=", c->param_service);
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling socket(%s, %s)",
+ c->param_hostname, c->param_service);
BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
goto exit_loop;
}
@@ -170,10 +169,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
ERR_clear_error();
break;
} else {
- FUNCerr("connect", get_last_socket_error());
- ERR_add_error_data(4,
- "hostname=", c->param_hostname,
- " service=", c->param_service);
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ "calling connect(%s, %s)",
+ c->param_hostname, c->param_service);
BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
}
goto exit_loop;
@@ -186,10 +184,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
i = BIO_sock_error(b->num);
if (i) {
BIO_clear_retry_flags(b);
- FUNCerr("connect", i);
- ERR_add_error_data(4,
- "hostname=", c->param_hostname,
- " service=", c->param_service);
+ ERR_raise_data(ERR_LIB_SYS, i,
+ "calling connect(%s, %s)",
+ c->param_hostname, c->param_service);
BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR);
ret = 0;
goto exit_loop;
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index 0aa6b713b6..c1acad9851 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -66,8 +66,9 @@ BIO *BIO_new_file(const char *filename, const char *mode)
fp_flags |= BIO_FP_TEXT;
if (file == NULL) {
- FUNCerr("fopen", get_last_sys_error());
- ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fopen(%s, %s)",
+ filename, mode);
if (errno == ENOENT
#ifdef ENXIO
|| errno == ENXIO
@@ -146,7 +147,8 @@ static int file_read(BIO *b, char *out, int outl)
if (ret == 0
&& (b->flags & BIO_FLAGS_UPLINK_INTERNAL
? UP_ferror((FILE *)b->ptr) : ferror((FILE *)b->ptr))) {
- FUNCerr("fread", get_last_sys_error());
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fread()");
BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB);
ret = -1;
}
@@ -285,8 +287,9 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
# endif
fp = openssl_fopen(ptr, p);
if (fp == NULL) {
- FUNCerr("fopen", get_last_sys_error());
- ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fopen(%s, %s)",
+ ptr, p);
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
ret = 0;
break;
@@ -313,8 +316,8 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
st = b->flags & BIO_FLAGS_UPLINK_INTERNAL
? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);
if (st == EOF) {
- FUNCerr("fflush", get_last_sys_error());
- ERR_add_error_data(1, "fflush()");
+ ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
+ "calling fflush()");
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
ret = 0;
}