[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 02/05: UTIL: fix memory leaks in several places.
From: |
gnunet |
Subject: |
[gnunet] 02/05: UTIL: fix memory leaks in several places. |
Date: |
Mon, 06 Feb 2023 05:41:12 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 1505f2f06b2d7f260811efee6597f725e4595e6c
Author: ulfvonbelow <strilen@tilde.club>
AuthorDate: Sat Jan 28 16:43:51 2023 -0600
UTIL: fix memory leaks in several places.
Namely, in:
- GNUNET_CRYPTO_eddsa_private_key_derive
- GNUNET_CRYPTO_hash_file_cancel
- GNUNET_CRYPTO_hash_file
- checkvec and check_vectors in gnunet-crypto-tvg
Signed-off-by: Martin Schanzenbach <schanzen@gnunet.org>
---
src/util/crypto_ecc_gnsrecord.c | 2 ++
src/util/crypto_hash_file.c | 2 ++
src/util/gnunet-crypto-tvg.c | 27 +++++++++++++++++----------
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/util/crypto_ecc_gnsrecord.c b/src/util/crypto_ecc_gnsrecord.c
index b902e0e0a..fc99bfc18 100644
--- a/src/util/crypto_ecc_gnsrecord.c
+++ b/src/util/crypto_ecc_gnsrecord.c
@@ -361,7 +361,9 @@ GNUNET_CRYPTO_eddsa_private_key_derive (
gcry_mpi_release (h);
gcry_mpi_release (x);
gcry_mpi_release (n);
+ gcry_mpi_release (h_mod_n);
gcry_mpi_release (a1);
+ gcry_mpi_release (eight);
gcry_mpi_release (a2);
gcry_ctx_release (ctx);
GNUNET_CRYPTO_mpi_print_unsigned (dc, sizeof(dc), d);
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c
index 7300bab29..96d364d2b 100644
--- a/src/util/crypto_hash_file.c
+++ b/src/util/crypto_hash_file.c
@@ -184,6 +184,7 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority
priority,
if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
{
GNUNET_break (0);
+ GNUNET_free (fhc->filename);
GNUNET_free (fhc);
return NULL;
}
@@ -227,6 +228,7 @@ GNUNET_CRYPTO_hash_file_cancel (struct
GNUNET_CRYPTO_FileHashContext *fhc)
GNUNET_free (fhc->filename);
GNUNET_break (GNUNET_OK ==
GNUNET_DISK_file_close (fhc->fh));
+ gcry_md_close (fhc->md);
GNUNET_free (fhc);
}
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c
index 4655407f0..5a16bb8fc 100644
--- a/src/util/gnunet-crypto-tvg.c
+++ b/src/util/gnunet-crypto-tvg.c
@@ -637,11 +637,12 @@ checkvec (const char *operation,
blinded_len)) )
{
GNUNET_free (blinded_data);
+ GNUNET_free (blinded_data_comp);
GNUNET_free (public_enc_data);
GNUNET_free (secret_enc_data);
GNUNET_free (sig_enc_data);
- GNUNET_free (skey);
- GNUNET_free (pkey);
+ GNUNET_CRYPTO_rsa_private_key_free (skey);
+ GNUNET_CRYPTO_rsa_public_key_free (pkey);
GNUNET_break (0);
return GNUNET_NO;
}
@@ -650,6 +651,7 @@ checkvec (const char *operation,
sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey);
GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_rsa_verify (&message_hash, sig,
pkey));
+ GNUNET_free(public_enc_data);
public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey,
&public_enc_data);
sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig,
@@ -658,25 +660,29 @@ checkvec (const char *operation,
if ( (sig_enc_length != sig_enc_length_comp) ||
(0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) ))
{
- GNUNET_free (blinded_sig);
+ GNUNET_CRYPTO_rsa_signature_free (blinded_sig);
GNUNET_free (blinded_data);
+ GNUNET_free (blinded_data_comp);
GNUNET_free (public_enc_data);
GNUNET_free (secret_enc_data);
GNUNET_free (sig_enc_data);
- GNUNET_free (skey);
- GNUNET_free (sig);
- GNUNET_free (pkey);
+ GNUNET_free (sig_enc_data_comp);
+ GNUNET_CRYPTO_rsa_private_key_free (skey);
+ GNUNET_CRYPTO_rsa_signature_free (sig);
+ GNUNET_CRYPTO_rsa_public_key_free (pkey);
GNUNET_break (0);
return GNUNET_NO;
}
- GNUNET_free (blinded_sig);
+ GNUNET_CRYPTO_rsa_signature_free (blinded_sig);
GNUNET_free (blinded_data);
+ GNUNET_free (blinded_data_comp);
GNUNET_free (public_enc_data);
GNUNET_free (secret_enc_data);
GNUNET_free (sig_enc_data);
- GNUNET_free (sig);
- GNUNET_free (pkey);
- GNUNET_free (skey);
+ GNUNET_free (sig_enc_data_comp);
+ GNUNET_CRYPTO_rsa_signature_free (sig);
+ GNUNET_CRYPTO_rsa_public_key_free (pkey);
+ GNUNET_CRYPTO_rsa_private_key_free (skey);
}
else if (0 == strcmp (operation, "cs_blind_signing"))
{
@@ -1009,6 +1015,7 @@ check_vectors ()
break;
}
}
+ json_decref (vecfile);
return (ret == GNUNET_OK) ? 0 : 1;
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.