summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Stange <nicstange@gmail.com>2016-05-26 23:19:52 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2016-05-31 16:42:00 +0800
commitc5ce7c697c983693c441573d2948e0ab8d62726e (patch)
treee3bde4c79e25699160ffeb1b50eed2c032a97a03
parent03cdfaad491e82e4a66593c6e149ddae0421df59 (diff)
lib/digsig: digsig_verify_rsa(): return -EINVAL if modulo length is zero
Currently, if digsig_verify_rsa() detects that the modulo's length is zero, i.e. mlen == 0, it returns -ENOMEM which doesn't really fit here. Make digsig_verify_rsa() return -EINVAL upon mlen == 0. Signed-off-by: Nicolai Stange <nicstange@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--lib/digsig.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/digsig.c b/lib/digsig.c
index a121cbc5a46b..55b8b2f41a9e 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -114,13 +114,15 @@ static int digsig_verify_rsa(struct key *key,
datap += remaining;
}
- err = -ENOMEM;
-
mblen = mpi_get_nbits(pkey[0]);
mlen = DIV_ROUND_UP(mblen, 8);
- if (mlen == 0)
+ if (mlen == 0) {
+ err = -EINVAL;
goto err;
+ }
+
+ err = -ENOMEM;
out1 = kzalloc(mlen, GFP_KERNEL);
if (!out1)