Commit ab802ee0 authored by David Howells's avatar David Howells

rxrpc: Clear the unused part of a sockaddr_rxrpc for memcmp() use

Clear the unused part of a sockaddr_rxrpc structs so that memcmp() can be
used to compare them.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 2b15ef15
...@@ -81,6 +81,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -81,6 +81,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
struct sockaddr_rxrpc *srx, struct sockaddr_rxrpc *srx,
int len) int len)
{ {
unsigned tail;
if (len < sizeof(struct sockaddr_rxrpc)) if (len < sizeof(struct sockaddr_rxrpc))
return -EINVAL; return -EINVAL;
...@@ -103,9 +105,7 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -103,9 +105,7 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
_debug("INET: %x @ %pI4", _debug("INET: %x @ %pI4",
ntohs(srx->transport.sin.sin_port), ntohs(srx->transport.sin.sin_port),
&srx->transport.sin.sin_addr); &srx->transport.sin.sin_addr);
if (srx->transport_len > 8) tail = offsetof(struct sockaddr_rxrpc, transport.sin.__pad);
memset((void *)&srx->transport + 8, 0,
srx->transport_len - 8);
break; break;
case AF_INET6: case AF_INET6:
...@@ -113,6 +113,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -113,6 +113,8 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
} }
if (tail < len)
memset((void *)srx + tail, 0, len - tail);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment