From: Erik Hugne <[email protected]>
Perform the address type validation after we check if it's a
connectionless socket, allowing TIPC_MULTICAST addresses to be
associated with RDM/DGRAM sockets. This was broken in the commit
listed below.
Fixes: 23998835be98 ("tipc: improve address sanity check in tipc_connect()")
Signed-off-by: Erik Hugne <[email protected]>
---
net/tipc/socket.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index e482b342bfa8..0ad8e6585adf 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2387,16 +2387,15 @@ static int tipc_connect(struct socket *sock, struct
sockaddr *dest,
} else if (dst->family != AF_TIPC) {
res = -EINVAL;
}
- if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME)
- res = -EINVAL;
- if (res)
- goto exit;
-
/* DGRAM/RDM connect(), just save the destaddr */
if (tipc_sk_type_connectionless(sk)) {
memcpy(&tsk->peer, dest, destlen);
goto exit;
}
+ if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME)
+ res = -EINVAL;
+ if (res)
+ goto exit;
previous = sk->sk_state;
--
2.14.1
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion