aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9a7e7b5cf23f..7659e792ecdb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1911,28 +1911,27 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
1911 int previous; 1911 int previous;
1912 int res = 0; 1912 int res = 0;
1913 1913
1914 if (destlen != sizeof(struct sockaddr_tipc))
1915 return -EINVAL;
1916
1914 lock_sock(sk); 1917 lock_sock(sk);
1915 1918
1916 /* DGRAM/RDM connect(), just save the destaddr */ 1919 if (dst->family == AF_UNSPEC) {
1917 if (tipc_sk_type_connectionless(sk)) { 1920 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc));
1918 if (dst->family == AF_UNSPEC) { 1921 if (!tipc_sk_type_connectionless(sk))
1919 memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc));
1920 } else if (destlen != sizeof(struct sockaddr_tipc)) {
1921 res = -EINVAL; 1922 res = -EINVAL;
1922 } else {
1923 memcpy(&tsk->peer, dest, destlen);
1924 }
1925 goto exit; 1923 goto exit;
1924 } else if (dst->family != AF_TIPC) {
1925 res = -EINVAL;
1926 } 1926 }
1927 1927 if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME)
1928 /*
1929 * Reject connection attempt using multicast address
1930 *
1931 * Note: send_msg() validates the rest of the address fields,
1932 * so there's no need to do it here
1933 */
1934 if (dst->addrtype == TIPC_ADDR_MCAST) {
1935 res = -EINVAL; 1928 res = -EINVAL;
1929 if (res)
1930 goto exit;
1931
1932 /* DGRAM/RDM connect(), just save the destaddr */
1933 if (tipc_sk_type_connectionless(sk)) {
1934 memcpy(&tsk->peer, dest, destlen);
1936 goto exit; 1935 goto exit;
1937 } 1936 }
1938 1937