diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-05-25 08:43:59 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-05-29 07:47:03 +0200 |
commit | 24c07e50551f73f565295db22478464ca9adc32e (patch) | |
tree | 185b2824424fb0add584a85b5d675c20708ab4f6 /crypto | |
parent | a7014122ac4d7b29e349e51028994581e8a73840 (diff) |
BIO acpt_state(): Allow retrying addresses (e.g., using IPv6 vs. IPv4) on creating accept socket
Fixes #15386
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15417)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/bss_acpt.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index aff92223af..834c2ffef1 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -216,18 +216,24 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) ERR_raise(ERR_LIB_BIO, BIO_R_LOOKUP_RETURNED_NOTHING); goto exit_loop; } - /* We're currently not iterating, but set this as preparation - * for possible future development in that regard - */ c->addr_iter = c->addr_first; c->state = ACPT_S_CREATE_SOCKET; break; case ACPT_S_CREATE_SOCKET: + ERR_set_mark(); 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) { + if ((c->addr_iter = BIO_ADDRINFO_next(c->addr_iter)) != NULL) { + /* + * if there are more addresses to try, do that first + */ + ERR_pop_to_mark(); + break; + } + ERR_clear_last_mark(); ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(), "calling socket(%s, %s)", c->param_addr, c->param_serv); |