aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/auth.c')
-rw-r--r--net/sctp/auth.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index d8420ae614dc..ba1dfc3f8def 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -200,27 +200,28 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector(
200 struct sctp_auth_bytes *new; 200 struct sctp_auth_bytes *new;
201 __u32 len; 201 __u32 len;
202 __u32 offset = 0; 202 __u32 offset = 0;
203 __u16 random_len, hmacs_len, chunks_len = 0;
203 204
204 len = ntohs(random->param_hdr.length) + ntohs(hmacs->param_hdr.length); 205 random_len = ntohs(random->param_hdr.length);
205 if (chunks) 206 hmacs_len = ntohs(hmacs->param_hdr.length);
206 len += ntohs(chunks->param_hdr.length); 207 if (chunks)
208 chunks_len = ntohs(chunks->param_hdr.length);
207 209
208 new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp); 210 len = random_len + hmacs_len + chunks_len;
211
212 new = sctp_auth_create_key(len, gfp);
209 if (!new) 213 if (!new)
210 return NULL; 214 return NULL;
211 215
212 new->len = len; 216 memcpy(new->data, random, random_len);
213 217 offset += random_len;
214 memcpy(new->data, random, ntohs(random->param_hdr.length));
215 offset += ntohs(random->param_hdr.length);
216 218
217 if (chunks) { 219 if (chunks) {
218 memcpy(new->data + offset, chunks, 220 memcpy(new->data + offset, chunks, chunks_len);
219 ntohs(chunks->param_hdr.length)); 221 offset += chunks_len;
220 offset += ntohs(chunks->param_hdr.length);
221 } 222 }
222 223
223 memcpy(new->data + offset, hmacs, ntohs(hmacs->param_hdr.length)); 224 memcpy(new->data + offset, hmacs, hmacs_len);
224 225
225 return new; 226 return new;
226} 227}
@@ -350,8 +351,8 @@ static struct sctp_auth_bytes *sctp_auth_asoc_create_secret(
350 secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector, 351 secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector,
351 gfp); 352 gfp);
352out: 353out:
353 kfree(local_key_vector); 354 sctp_auth_key_put(local_key_vector);
354 kfree(peer_key_vector); 355 sctp_auth_key_put(peer_key_vector);
355 356
356 return secret; 357 return secret;
357} 358}