aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/bind_addr.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/bind_addr.c')
-rw-r--r--net/sctp/bind_addr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index 871cdf9567e6..401c60750b20 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -111,7 +111,8 @@ int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
111 dest->port = src->port; 111 dest->port = src->port;
112 112
113 list_for_each_entry(addr, &src->address_list, list) { 113 list_for_each_entry(addr, &src->address_list, list) {
114 error = sctp_add_bind_addr(dest, &addr->a, 1, gfp); 114 error = sctp_add_bind_addr(dest, &addr->a, sizeof(addr->a),
115 1, gfp);
115 if (error < 0) 116 if (error < 0)
116 break; 117 break;
117 } 118 }
@@ -150,7 +151,7 @@ void sctp_bind_addr_free(struct sctp_bind_addr *bp)
150 151
151/* Add an address to the bind address list in the SCTP_bind_addr structure. */ 152/* Add an address to the bind address list in the SCTP_bind_addr structure. */
152int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new, 153int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
153 __u8 addr_state, gfp_t gfp) 154 int new_size, __u8 addr_state, gfp_t gfp)
154{ 155{
155 struct sctp_sockaddr_entry *addr; 156 struct sctp_sockaddr_entry *addr;
156 157
@@ -159,7 +160,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
159 if (!addr) 160 if (!addr)
160 return -ENOMEM; 161 return -ENOMEM;
161 162
162 memcpy(&addr->a, new, sizeof(*new)); 163 memcpy(&addr->a, new, min_t(size_t, sizeof(*new), new_size));
163 164
164 /* Fix up the port if it has not yet been set. 165 /* Fix up the port if it has not yet been set.
165 * Both v4 and v6 have the port at the same offset. 166 * Both v4 and v6 have the port at the same offset.
@@ -291,7 +292,8 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
291 } 292 }
292 293
293 af->from_addr_param(&addr, rawaddr, htons(port), 0); 294 af->from_addr_param(&addr, rawaddr, htons(port), 0);
294 retval = sctp_add_bind_addr(bp, &addr, SCTP_ADDR_SRC, gfp); 295 retval = sctp_add_bind_addr(bp, &addr, sizeof(addr),
296 SCTP_ADDR_SRC, gfp);
295 if (retval) { 297 if (retval) {
296 /* Can't finish building the list, clean up. */ 298 /* Can't finish building the list, clean up. */
297 sctp_bind_addr_clean(bp); 299 sctp_bind_addr_clean(bp);
@@ -453,8 +455,8 @@ static int sctp_copy_one_addr(struct net *net, struct sctp_bind_addr *dest,
453 (((AF_INET6 == addr->sa.sa_family) && 455 (((AF_INET6 == addr->sa.sa_family) &&
454 (flags & SCTP_ADDR6_ALLOWED) && 456 (flags & SCTP_ADDR6_ALLOWED) &&
455 (flags & SCTP_ADDR6_PEERSUPP)))) 457 (flags & SCTP_ADDR6_PEERSUPP))))
456 error = sctp_add_bind_addr(dest, addr, SCTP_ADDR_SRC, 458 error = sctp_add_bind_addr(dest, addr, sizeof(*addr),
457 gfp); 459 SCTP_ADDR_SRC, gfp);
458 } 460 }
459 461
460 return error; 462 return error;