aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2fc0a92caa78..b2ffab62a229 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -972,6 +972,7 @@ static int __sctp_connect(struct sock* sk,
972 int walk_size = 0; 972 int walk_size = 0;
973 union sctp_addr *sa_addr; 973 union sctp_addr *sa_addr;
974 void *addr_buf; 974 void *addr_buf;
975 unsigned short port;
975 976
976 sp = sctp_sk(sk); 977 sp = sctp_sk(sk);
977 ep = sp->ep; 978 ep = sp->ep;
@@ -992,6 +993,7 @@ static int __sctp_connect(struct sock* sk,
992 while (walk_size < addrs_size) { 993 while (walk_size < addrs_size) {
993 sa_addr = (union sctp_addr *)addr_buf; 994 sa_addr = (union sctp_addr *)addr_buf;
994 af = sctp_get_af_specific(sa_addr->sa.sa_family); 995 af = sctp_get_af_specific(sa_addr->sa.sa_family);
996 port = ntohs(sa_addr->v4.sin_port);
995 997
996 /* If the address family is not supported or if this address 998 /* If the address family is not supported or if this address
997 * causes the address buffer to overflow return EINVAL. 999 * causes the address buffer to overflow return EINVAL.
@@ -1005,6 +1007,12 @@ static int __sctp_connect(struct sock* sk,
1005 if (err) 1007 if (err)
1006 goto out_free; 1008 goto out_free;
1007 1009
1010 /* Make sure the destination port is correctly set
1011 * in all addresses.
1012 */
1013 if (asoc && asoc->peer.port && asoc->peer.port != port)
1014 goto out_free;
1015
1008 memcpy(&to, sa_addr, af->sockaddr_len); 1016 memcpy(&to, sa_addr, af->sockaddr_len);
1009 1017
1010 /* Check if there already is a matching association on the 1018 /* Check if there already is a matching association on the