diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index e118e3c1285e..a3e1ca2c3cb7 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3867,14 +3867,14 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len, | |||
3867 | if (sctp_list_single_entry(&bp->address_list)) { | 3867 | if (sctp_list_single_entry(&bp->address_list)) { |
3868 | addr = list_entry(bp->address_list.next, | 3868 | addr = list_entry(bp->address_list.next, |
3869 | struct sctp_sockaddr_entry, list); | 3869 | struct sctp_sockaddr_entry, list); |
3870 | if (sctp_is_any(&addr->a_h)) { | 3870 | if (sctp_is_any(&addr->a)) { |
3871 | sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); | 3871 | sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); |
3872 | list_for_each(pos, &sctp_local_addr_list) { | 3872 | list_for_each(pos, &sctp_local_addr_list) { |
3873 | addr = list_entry(pos, | 3873 | addr = list_entry(pos, |
3874 | struct sctp_sockaddr_entry, | 3874 | struct sctp_sockaddr_entry, |
3875 | list); | 3875 | list); |
3876 | if ((PF_INET == sk->sk_family) && | 3876 | if ((PF_INET == sk->sk_family) && |
3877 | (AF_INET6 == addr->a_h.sa.sa_family)) | 3877 | (AF_INET6 == addr->a.sa.sa_family)) |
3878 | continue; | 3878 | continue; |
3879 | cnt++; | 3879 | cnt++; |
3880 | } | 3880 | } |
@@ -3912,13 +3912,12 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add | |||
3912 | list_for_each(pos, &sctp_local_addr_list) { | 3912 | list_for_each(pos, &sctp_local_addr_list) { |
3913 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | 3913 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); |
3914 | if ((PF_INET == sk->sk_family) && | 3914 | if ((PF_INET == sk->sk_family) && |
3915 | (AF_INET6 == addr->a_h.sa.sa_family)) | 3915 | (AF_INET6 == addr->a.sa.sa_family)) |
3916 | continue; | 3916 | continue; |
3917 | memcpy(&temp, &addr->a_h, sizeof(temp)); | 3917 | memcpy(&temp, &addr->a, sizeof(temp)); |
3918 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), | 3918 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), |
3919 | &temp); | 3919 | &temp); |
3920 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 3920 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
3921 | temp.v4.sin_port = htons(port); | ||
3922 | if (copy_to_user(to, &temp, addrlen)) { | 3921 | if (copy_to_user(to, &temp, addrlen)) { |
3923 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, | 3922 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, |
3924 | flags); | 3923 | flags); |
@@ -3947,15 +3946,14 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, | |||
3947 | list_for_each(pos, &sctp_local_addr_list) { | 3946 | list_for_each(pos, &sctp_local_addr_list) { |
3948 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | 3947 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); |
3949 | if ((PF_INET == sk->sk_family) && | 3948 | if ((PF_INET == sk->sk_family) && |
3950 | (AF_INET6 == addr->a_h.sa.sa_family)) | 3949 | (AF_INET6 == addr->a.sa.sa_family)) |
3951 | continue; | 3950 | continue; |
3952 | memcpy(&temp, &addr->a_h, sizeof(temp)); | 3951 | memcpy(&temp, &addr->a, sizeof(temp)); |
3953 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), | 3952 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), |
3954 | &temp); | 3953 | &temp); |
3955 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 3954 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
3956 | if(space_left<addrlen) | 3955 | if(space_left<addrlen) |
3957 | return -ENOMEM; | 3956 | return -ENOMEM; |
3958 | temp.v4.sin_port = htons(port); | ||
3959 | if (copy_to_user(*to, &temp, addrlen)) { | 3957 | if (copy_to_user(*to, &temp, addrlen)) { |
3960 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, | 3958 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, |
3961 | flags); | 3959 | flags); |
@@ -4023,7 +4021,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, | |||
4023 | if (sctp_list_single_entry(&bp->address_list)) { | 4021 | if (sctp_list_single_entry(&bp->address_list)) { |
4024 | addr = list_entry(bp->address_list.next, | 4022 | addr = list_entry(bp->address_list.next, |
4025 | struct sctp_sockaddr_entry, list); | 4023 | struct sctp_sockaddr_entry, list); |
4026 | if (sctp_is_any(&addr->a_h)) { | 4024 | if (sctp_is_any(&addr->a)) { |
4027 | cnt = sctp_copy_laddrs_to_user_old(sk, bp->port, | 4025 | cnt = sctp_copy_laddrs_to_user_old(sk, bp->port, |
4028 | getaddrs.addr_num, | 4026 | getaddrs.addr_num, |
4029 | to); | 4027 | to); |
@@ -4037,10 +4035,9 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, | |||
4037 | 4035 | ||
4038 | list_for_each(pos, &bp->address_list) { | 4036 | list_for_each(pos, &bp->address_list) { |
4039 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | 4037 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); |
4040 | memcpy(&temp, &addr->a_h, sizeof(temp)); | 4038 | memcpy(&temp, &addr->a, sizeof(temp)); |
4041 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); | 4039 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); |
4042 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 4040 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
4043 | temp.v4.sin_port = htons(temp.v4.sin_port); | ||
4044 | if (copy_to_user(to, &temp, addrlen)) { | 4041 | if (copy_to_user(to, &temp, addrlen)) { |
4045 | err = -EFAULT; | 4042 | err = -EFAULT; |
4046 | goto unlock; | 4043 | goto unlock; |
@@ -4113,7 +4110,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | |||
4113 | if (sctp_list_single_entry(&bp->address_list)) { | 4110 | if (sctp_list_single_entry(&bp->address_list)) { |
4114 | addr = list_entry(bp->address_list.next, | 4111 | addr = list_entry(bp->address_list.next, |
4115 | struct sctp_sockaddr_entry, list); | 4112 | struct sctp_sockaddr_entry, list); |
4116 | if (sctp_is_any(&addr->a_h)) { | 4113 | if (sctp_is_any(&addr->a)) { |
4117 | cnt = sctp_copy_laddrs_to_user(sk, bp->port, | 4114 | cnt = sctp_copy_laddrs_to_user(sk, bp->port, |
4118 | &to, space_left); | 4115 | &to, space_left); |
4119 | if (cnt < 0) { | 4116 | if (cnt < 0) { |
@@ -4126,12 +4123,11 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | |||
4126 | 4123 | ||
4127 | list_for_each(pos, &bp->address_list) { | 4124 | list_for_each(pos, &bp->address_list) { |
4128 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | 4125 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); |
4129 | memcpy(&temp, &addr->a_h, sizeof(temp)); | 4126 | memcpy(&temp, &addr->a, sizeof(temp)); |
4130 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); | 4127 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); |
4131 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | 4128 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
4132 | if(space_left < addrlen) | 4129 | if(space_left < addrlen) |
4133 | return -ENOMEM; /*fixme: right error?*/ | 4130 | return -ENOMEM; /*fixme: right error?*/ |
4134 | temp.v4.sin_port = htons(temp.v4.sin_port); | ||
4135 | if (copy_to_user(to, &temp, addrlen)) { | 4131 | if (copy_to_user(to, &temp, addrlen)) { |
4136 | err = -EFAULT; | 4132 | err = -EFAULT; |
4137 | goto unlock; | 4133 | goto unlock; |