Skip to content
This repository has been archived by the owner on Dec 29, 2017. It is now read-only.

Commit

Permalink
lib/digsig: digsig_verify_rsa(): return -EINVAL if modulo length is zero
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
nicstange authored and herbertx committed May 31, 2016
1 parent 03cdfaa commit c5ce7c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/digsig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c5ce7c6

Please sign in to comment.