diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d4bf2a78cb8a..e34ca9cc1167 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -918,6 +918,11 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk, | |||
918 | /* Walk through the addrs buffer and count the number of addresses. */ | 918 | /* Walk through the addrs buffer and count the number of addresses. */ |
919 | addr_buf = kaddrs; | 919 | addr_buf = kaddrs; |
920 | while (walk_size < addrs_size) { | 920 | while (walk_size < addrs_size) { |
921 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | ||
922 | kfree(kaddrs); | ||
923 | return -EINVAL; | ||
924 | } | ||
925 | |||
921 | sa_addr = (struct sockaddr *)addr_buf; | 926 | sa_addr = (struct sockaddr *)addr_buf; |
922 | af = sctp_get_af_specific(sa_addr->sa_family); | 927 | af = sctp_get_af_specific(sa_addr->sa_family); |
923 | 928 | ||
@@ -1004,9 +1009,13 @@ static int __sctp_connect(struct sock* sk, | |||
1004 | /* Walk through the addrs buffer and count the number of addresses. */ | 1009 | /* Walk through the addrs buffer and count the number of addresses. */ |
1005 | addr_buf = kaddrs; | 1010 | addr_buf = kaddrs; |
1006 | while (walk_size < addrs_size) { | 1011 | while (walk_size < addrs_size) { |
1012 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | ||
1013 | err = -EINVAL; | ||
1014 | goto out_free; | ||
1015 | } | ||
1016 | |||
1007 | sa_addr = (union sctp_addr *)addr_buf; | 1017 | sa_addr = (union sctp_addr *)addr_buf; |
1008 | af = sctp_get_af_specific(sa_addr->sa.sa_family); | 1018 | af = sctp_get_af_specific(sa_addr->sa.sa_family); |
1009 | port = ntohs(sa_addr->v4.sin_port); | ||
1010 | 1019 | ||
1011 | /* If the address family is not supported or if this address | 1020 | /* If the address family is not supported or if this address |
1012 | * causes the address buffer to overflow return EINVAL. | 1021 | * causes the address buffer to overflow return EINVAL. |
@@ -1016,6 +1025,8 @@ static int __sctp_connect(struct sock* sk, | |||
1016 | goto out_free; | 1025 | goto out_free; |
1017 | } | 1026 | } |
1018 | 1027 | ||
1028 | port = ntohs(sa_addr->v4.sin_port); | ||
1029 | |||
1019 | /* Save current address so we can work with it */ | 1030 | /* Save current address so we can work with it */ |
1020 | memcpy(&to, sa_addr, af->sockaddr_len); | 1031 | memcpy(&to, sa_addr, af->sockaddr_len); |
1021 | 1032 | ||