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
* @options: BIO socket options, applied on the accepted socket.
*
*/
-int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options)
+int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
{
socklen_t len;
int accepted_sock;
+ BIO_ADDR locaddr;
+ BIO_ADDR *addr = addr_ == NULL ? &locaddr : addr_;
len = sizeof(*addr);
accepted_sock = accept(accept_sock,