diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-01-03 13:54:16 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2017-01-03 18:31:32 +0100 |
commit | 11540d02d274679ef8feb1c703a0766339f033a8 (patch) | |
tree | aa520e777af7ef4564785ae5cceb63203f1bb096 | |
parent | f8ad54fa7b35f0b122caf993c6e5087de48c3c1a (diff) | |
download | nettle-11540d02d274679ef8feb1c703a0766339f033a8.tar.gz |
ecdsa_verify: eliminated memory leak on error path
-rw-r--r-- | ecdsa-verify.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ecdsa-verify.c b/ecdsa-verify.c index 05c174ec..ab8e19f3 100644 --- a/ecdsa-verify.c +++ b/ecdsa-verify.c @@ -52,7 +52,7 @@ ecdsa_verify (const struct ecc_point *pub, /* For ECC_MUL_A_WBITS == 0, at most 1512 bytes. With ECC_MUL_A_WBITS == 4, currently needs 67 * ecc->size, at most 4824 bytes. Don't use stack allocation for this. */ - mp_limb_t *scratch = gmp_alloc_limbs (itch); + mp_limb_t *scratch; int res; #define rp scratch @@ -62,6 +62,8 @@ ecdsa_verify (const struct ecc_point *pub, if (mpz_sgn (signature->r) <= 0 || mpz_size (signature->r) > size || mpz_sgn (signature->s) <= 0 || mpz_size (signature->s) > size) return 0; + + scratch = gmp_alloc_limbs (itch); mpz_limbs_copy (rp, signature->r, size); mpz_limbs_copy (sp, signature->s, size); |