View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007619 | GNUnet | util library | public | 2023-01-29 21:17 | 2024-02-29 22:46 |
Reporter | ulfvonbelow | Assigned To | schanzen | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | Git master | ||||
Target Version | 0.19.4 | Fixed in Version | 0.19.4 | ||
Summary | 0007619: Memory leaks in util | ||||
Description | In GNUNET_CRYPTO_eddsa_private_key_derive, GNUNET_CRYPTO_hash_file_cancel, GNUNET_CRYPTO_hash_file, and the checkvec and check_vectors functions in gnunet-crypto-tvg. See attached patch for details. | ||||
Steps To Reproduce | ./configure --enable-sanitizer make make install make check | ||||
Additional Information | Patch attached. | ||||
Tags | memory-leak, patch | ||||
Attached Files | 0001-UTIL-fix-memory-leaks-in-several-places.patch (4,550 bytes)
From 80c414ec8768cc4a15f0a8689e689af98d90ae21 Mon Sep 17 00:00:00 2001 From: ulfvonbelow <strilen@tilde.club> Date: Sat, 28 Jan 2023 16:43:51 -0600 Subject: [PATCH] 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 --- 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; } } -- 2.38.1 | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2023-01-29 21:17 | ulfvonbelow | New Issue | |
2023-01-29 21:17 | ulfvonbelow | Tag Attached: bug | |
2023-01-29 21:17 | ulfvonbelow | Tag Attached: memory-leak | |
2023-01-29 21:17 | ulfvonbelow | Tag Attached: patch | |
2023-01-29 21:17 | ulfvonbelow | File Added: 0001-UTIL-fix-memory-leaks-in-several-places.patch | |
2023-02-06 05:30 | schanzen | Assigned To | => schanzen |
2023-02-06 05:30 | schanzen | Status | new => resolved |
2023-02-06 05:30 | schanzen | Resolution | open => fixed |
2023-02-06 05:30 | schanzen | Fixed in Version | => 0.19.4 |
2023-02-06 05:30 | schanzen | Note Added: 0019758 | |
2023-02-06 05:46 | schanzen | Target Version | => 0.19.4 |
2023-06-01 20:26 | schanzen | Note Added: 0020246 | |
2023-06-01 20:26 | schanzen | Status | resolved => closed |
2024-02-29 22:46 | Christian Grothoff | Tag Detached: bug |