summaryrefslogtreecommitdiff
path: root/cipher/ecc-eddsa.c
diff options
context:
space:
mode:
authorIsmo Puustinen <ismo.puustinen@intel.com>2015-08-05 15:27:43 +0300
committerWerner Koch <wk@gnupg.org>2015-08-06 14:52:42 +0200
commit1d896371fbc94c605fce35eabcde01e24dd22892 (patch)
treeaf3fa18bb1d966dab931154fd7ce940d4573b144 /cipher/ecc-eddsa.c
parente93f4c21c59756604440ad8cbf27e67d29c99ffd (diff)
downloadlibgcrypt-1d896371fbc94c605fce35eabcde01e24dd22892.tar.gz
ecc: Free memory also when in error branch.
* cipher/ecc-eddsa.c (_gcry_ecc_eddsa_sign): Init DISGEST and goto leave on error. -- Fixing an issue found by static analysis. Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com> Added DIGEST init and wrote Changelog. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/ecc-eddsa.c')
-rw-r--r--cipher/ecc-eddsa.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cipher/ecc-eddsa.c b/cipher/ecc-eddsa.c
index 4323d8ef..1e954896 100644
--- a/cipher/ecc-eddsa.c
+++ b/cipher/ecc-eddsa.c
@@ -580,7 +580,7 @@ _gcry_ecc_eddsa_sign (gcry_mpi_t input, ECC_secret_key *skey,
mpi_ec_t ctx = NULL;
int b;
unsigned int tmp;
- unsigned char *digest;
+ unsigned char *digest = NULL;
gcry_buffer_t hvec[3];
const void *mbuf;
size_t mlen;
@@ -607,8 +607,10 @@ _gcry_ecc_eddsa_sign (gcry_mpi_t input, ECC_secret_key *skey,
ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0,
skey->E.p, skey->E.a, skey->E.b);
b = (ctx->nbits+7)/8;
- if (b != 256/8)
- return GPG_ERR_INTERNAL; /* We only support 256 bit. */
+ if (b != 256/8) {
+ rc = GPG_ERR_INTERNAL; /* We only support 256 bit. */
+ goto leave;
+ }
rc = _gcry_ecc_eddsa_compute_h_d (&digest, skey->d, ctx);
if (rc)