bss_dgram.c: Use BIO_ADDR_sockaddr() and BIO_ADDR_sockaddr_size()

Especially, it's important to use BIO_ADDR_sockaddr_size() instead of
taking sizeof(addr), as BIO_ADDR is a union of several sockaddr variants
with different sizes, and some sendto() implementations are very picky
that the size is correct for the indicated sockaddr family.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20449)
This commit is contained in:
Richard Levitte 2023-03-07 15:18:18 +01:00
parent ac57336cd2
commit a8681703d4

View File

@ -1423,8 +1423,8 @@ static int dgram_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride,
msg[0].data_len,
# endif
sysflags,
msg[0].peer != NULL ? &msg[0].peer->sa : NULL,
msg[0].peer != NULL ? sizeof(*msg[0].peer) : 0);
msg[0].peer != NULL ? BIO_ADDR_sockaddr(msg[0].peer) : NULL,
msg[0].peer != NULL ? BIO_ADDR_sockaddr_size(msg[0].peer) : 0);
if (ret <= 0) {
ERR_raise(ERR_LIB_SYS, get_last_socket_error());
*num_processed = 0;