From 92ad9a3b4e56f153d9460bef8a06d8705a68b6c6 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 9 Jul 2010 12:05:02 +0200 Subject: sparse: Avoid variable-length arrays Signed-off-by: Nikos Mavrogiannopoulos --- ncr-key-wrap.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ncr-key-wrap.c b/ncr-key-wrap.c index cec850e..41a7aea 100644 --- a/ncr-key-wrap.c +++ b/ncr-key-wrap.c @@ -142,8 +142,14 @@ uint8_t iv[8]; } { - val64_t R[n]; + val64_t *R; + R = kmalloc(n * sizeof (*R), GFP_KERNEL); + if (R == NULL) { + err(); + ret = -ENOMEM; + goto cleanup; + } /* R = P */ for (i=0;i n*8 || size < (n-1)*8 || *kdata_size < size) { err(); + kfree(R); ret = -EINVAL; goto cleanup; } @@ -233,6 +249,7 @@ size_t size; for (i=0;ikey.secret.data)/8 + 1]; ret = rfc3394_unwrap(wrapped_key, R, n, A, &ctx); if (ret < 0) { -- cgit