Skip to content

Commit

Permalink
SCTP: Fix sctp_getsockopt_get_peer_addrs
Browse files Browse the repository at this point in the history
	This is the split out of the patch that we agreed I should split
out from my last patch.  It changes space_left to be computed in the same
way the to variable is.  I know we talked about changing space_left to an
int, but I think size_t is more appropriate, since we should never have
negative space in our buffer, and computing using offsetof means space_left
should now never drop below zero.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
  • Loading branch information
Neil Horman authored and Vlad Yasevich committed Jun 19, 2007
1 parent 408f22e commit 186e234
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -4019,8 +4019,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
return -EINVAL;

to = optval + offsetof(struct sctp_getaddrs,addrs);
space_left = len - sizeof(struct sctp_getaddrs) -
offsetof(struct sctp_getaddrs,addrs);
space_left = len - offsetof(struct sctp_getaddrs,addrs);

list_for_each(pos, &asoc->peer.transport_addr_list) {
from = list_entry(pos, struct sctp_transport, transports);
Expand Down Expand Up @@ -4327,8 +4326,8 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
}

to = optval + offsetof(struct sctp_getaddrs,addrs);
space_left = len - sizeof(struct sctp_getaddrs) -
offsetof(struct sctp_getaddrs,addrs);
space_left = len - offsetof(struct sctp_getaddrs,addrs);

addrs = kmalloc(space_left, GFP_KERNEL);
if (!addrs)
return -ENOMEM;
Expand Down

0 comments on commit 186e234

Please sign in to comment.