diff options
author | scott <scott.morgan@hibiscus-plc.com> | 2020-04-09 12:36:37 +0100 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2020-04-14 11:51:41 +0200 |
commit | 0437435a960123be1ced766d18d715f939698345 (patch) | |
tree | 0a501f5b516a73175a48c60e95e8eee675889a68 /crypto | |
parent | b93e2ec273f8a6e7165fddaae1fe75615c0edf5a (diff) |
BIO_do_accept: correct error return value
`BIO_do_accept` was returning incorrect values when unable to bind to a port.
Fixes #7717
CLA: trivial
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11505)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/bss_acpt.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index a3b3f21cab..d5b29ecf9e 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -222,19 +222,20 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) break; case ACPT_S_CREATE_SOCKET: - ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), - BIO_ADDRINFO_socktype(c->addr_iter), - BIO_ADDRINFO_protocol(c->addr_iter), 0); - if (ret == (int)INVALID_SOCKET) { + s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), + BIO_ADDRINFO_socktype(c->addr_iter), + BIO_ADDRINFO_protocol(c->addr_iter), 0); + if (s == (int)INVALID_SOCKET) { 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; } - c->accept_sock = ret; - b->num = ret; + c->accept_sock = s; + b->num = s; c->state = ACPT_S_LISTEN; + s = -1; break; case ACPT_S_LISTEN: |