diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-08-09 08:26:27 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-08-09 08:26:27 +0900 |
commit | 2b5bbe264fcd61e5e458e5f71a6507ba0271c729 (patch) | |
tree | a90ab73e6497a93e2b78a82923079191aba7b81b /cipher/pubkey.c | |
parent | 426cbc9feca0c8f46208fb3670adab95f9e46087 (diff) | |
download | libgcrypt-2b5bbe264fcd61e5e458e5f71a6507ba0271c729.tar.gz |
cipher: fix memory leak.
* cipher/pubkey.c (gcry_pk_sign): Handle the specific case of ECC,
where there is NULL whichi is not the sentinel.
--
This is a kind of makeshift fix, but the MPI array API is internal
only and will be removed, it is better not to change API now.
Diffstat (limited to 'cipher/pubkey.c')
-rw-r--r-- | cipher/pubkey.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/cipher/pubkey.c b/cipher/pubkey.c index e8671697..e6c1cf67 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -3339,7 +3339,16 @@ gcry_pk_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_hash, gcry_sexp_t s_skey) leave: if (skey) { - release_mpi_array (skey); + if (is_ecc) + /* Q is optional and may be NULL, while there is D after Q. */ + for (i = 0; i < 7; i++) + { + if (skey[i]) + mpi_free (skey[i]); + skey[i] = NULL; + } + else + release_mpi_array (skey); gcry_free (skey); } |