aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorulfvonbelow <strilen@tilde.club>2023-01-28 16:43:51 -0600
committerMartin Schanzenbach <schanzen@gnunet.org>2023-02-06 13:29:38 +0900
commit1505f2f06b2d7f260811efee6597f725e4595e6c (patch)
treee08b02f24519461e4e2e69f180505faaecfdb91d /src/util
parent4b227ccb101f66fbfec10b952589450403f95678 (diff)
downloadgnunet-1505f2f06b2d7f260811efee6597f725e4595e6c.tar.gz
gnunet-1505f2f06b2d7f260811efee6597f725e4595e6c.zip
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>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_ecc_gnsrecord.c2
-rw-r--r--src/util/crypto_hash_file.c2
-rw-r--r--src/util/gnunet-crypto-tvg.c27
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 (
361 gcry_mpi_release (h); 361 gcry_mpi_release (h);
362 gcry_mpi_release (x); 362 gcry_mpi_release (x);
363 gcry_mpi_release (n); 363 gcry_mpi_release (n);
364 gcry_mpi_release (h_mod_n);
364 gcry_mpi_release (a1); 365 gcry_mpi_release (a1);
366 gcry_mpi_release (eight);
365 gcry_mpi_release (a2); 367 gcry_mpi_release (a2);
366 gcry_ctx_release (ctx); 368 gcry_ctx_release (ctx);
367 GNUNET_CRYPTO_mpi_print_unsigned (dc, sizeof(dc), d); 369 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,
184 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) 184 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
185 { 185 {
186 GNUNET_break (0); 186 GNUNET_break (0);
187 GNUNET_free (fhc->filename);
187 GNUNET_free (fhc); 188 GNUNET_free (fhc);
188 return NULL; 189 return NULL;
189 } 190 }
@@ -227,6 +228,7 @@ GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc)
227 GNUNET_free (fhc->filename); 228 GNUNET_free (fhc->filename);
228 GNUNET_break (GNUNET_OK == 229 GNUNET_break (GNUNET_OK ==
229 GNUNET_DISK_file_close (fhc->fh)); 230 GNUNET_DISK_file_close (fhc->fh));
231 gcry_md_close (fhc->md);
230 GNUNET_free (fhc); 232 GNUNET_free (fhc);
231} 233}
232 234
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,
637 blinded_len)) ) 637 blinded_len)) )
638 { 638 {
639 GNUNET_free (blinded_data); 639 GNUNET_free (blinded_data);
640 GNUNET_free (blinded_data_comp);
640 GNUNET_free (public_enc_data); 641 GNUNET_free (public_enc_data);
641 GNUNET_free (secret_enc_data); 642 GNUNET_free (secret_enc_data);
642 GNUNET_free (sig_enc_data); 643 GNUNET_free (sig_enc_data);
643 GNUNET_free (skey); 644 GNUNET_CRYPTO_rsa_private_key_free (skey);
644 GNUNET_free (pkey); 645 GNUNET_CRYPTO_rsa_public_key_free (pkey);
645 GNUNET_break (0); 646 GNUNET_break (0);
646 return GNUNET_NO; 647 return GNUNET_NO;
647 } 648 }
@@ -650,6 +651,7 @@ checkvec (const char *operation,
650 sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey); 651 sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey);
651 GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_rsa_verify (&message_hash, sig, 652 GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_rsa_verify (&message_hash, sig,
652 pkey)); 653 pkey));
654 GNUNET_free(public_enc_data);
653 public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey, 655 public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey,
654 &public_enc_data); 656 &public_enc_data);
655 sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig, 657 sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig,
@@ -658,25 +660,29 @@ checkvec (const char *operation,
658 if ( (sig_enc_length != sig_enc_length_comp) || 660 if ( (sig_enc_length != sig_enc_length_comp) ||
659 (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) )) 661 (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) ))
660 { 662 {
661 GNUNET_free (blinded_sig); 663 GNUNET_CRYPTO_rsa_signature_free (blinded_sig);
662 GNUNET_free (blinded_data); 664 GNUNET_free (blinded_data);
665 GNUNET_free (blinded_data_comp);
663 GNUNET_free (public_enc_data); 666 GNUNET_free (public_enc_data);
664 GNUNET_free (secret_enc_data); 667 GNUNET_free (secret_enc_data);
665 GNUNET_free (sig_enc_data); 668 GNUNET_free (sig_enc_data);
666 GNUNET_free (skey); 669 GNUNET_free (sig_enc_data_comp);
667 GNUNET_free (sig); 670 GNUNET_CRYPTO_rsa_private_key_free (skey);
668 GNUNET_free (pkey); 671 GNUNET_CRYPTO_rsa_signature_free (sig);
672 GNUNET_CRYPTO_rsa_public_key_free (pkey);
669 GNUNET_break (0); 673 GNUNET_break (0);
670 return GNUNET_NO; 674 return GNUNET_NO;
671 } 675 }
672 GNUNET_free (blinded_sig); 676 GNUNET_CRYPTO_rsa_signature_free (blinded_sig);
673 GNUNET_free (blinded_data); 677 GNUNET_free (blinded_data);
678 GNUNET_free (blinded_data_comp);
674 GNUNET_free (public_enc_data); 679 GNUNET_free (public_enc_data);
675 GNUNET_free (secret_enc_data); 680 GNUNET_free (secret_enc_data);
676 GNUNET_free (sig_enc_data); 681 GNUNET_free (sig_enc_data);
677 GNUNET_free (sig); 682 GNUNET_free (sig_enc_data_comp);
678 GNUNET_free (pkey); 683 GNUNET_CRYPTO_rsa_signature_free (sig);
679 GNUNET_free (skey); 684 GNUNET_CRYPTO_rsa_public_key_free (pkey);
685 GNUNET_CRYPTO_rsa_private_key_free (skey);
680 } 686 }
681 else if (0 == strcmp (operation, "cs_blind_signing")) 687 else if (0 == strcmp (operation, "cs_blind_signing"))
682 { 688 {
@@ -1009,6 +1015,7 @@ check_vectors ()
1009 break; 1015 break;
1010 } 1016 }
1011 } 1017 }
1018 json_decref (vecfile);
1012 return (ret == GNUNET_OK) ? 0 : 1; 1019 return (ret == GNUNET_OK) ? 0 : 1;
1013 } 1020 }
1014} 1021}