gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 01/03: -logging, minor memory leak fix


From: gnunet
Subject: [gnunet] 01/03: -logging, minor memory leak fix
Date: Wed, 30 Mar 2022 10:29:24 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit edf6f59fac12cd6f7d0a14ecf2a47ab82a8beb17
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sun Mar 27 15:35:14 2022 +0200

    -logging, minor memory leak fix
---
 src/pq/pq_result_helper.c |  6 ++++++
 src/util/crypto_kdf.c     |  9 +++++----
 src/util/crypto_rsa.c     | 20 +++++++++++++-------
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index 2c11f5202..f3d246c36 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -1086,6 +1086,12 @@ extract_uint64 (void *cls,
                    fnum))
   {
     GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Got length %u for field `%s'\n",
+                PQgetlength (result,
+                             row,
+                             fnum),
+                fname);
     return GNUNET_SYSERR;
   }
   res = (uint64_t *) PQgetvalue (result,
diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c
index 0dc734549..8041f61ab 100644
--- a/src/util/crypto_kdf.c
+++ b/src/util/crypto_kdf.c
@@ -43,7 +43,7 @@
  * @param argp va_list of void * & size_t pairs for context chunks
  * @return #GNUNET_YES on success
  */
-int
+enum GNUNET_GenericReturnValue
 GNUNET_CRYPTO_kdf_v (void *result,
                      size_t out_len,
                      const void *xts,
@@ -62,7 +62,7 @@ GNUNET_CRYPTO_kdf_v (void *result,
    * hash function."
    *
    * http://eprint.iacr.org/2010/264
-   *///
+   */
   return GNUNET_CRYPTO_hkdf_v (result,
                                out_len,
                                GCRY_MD_SHA512,
@@ -86,7 +86,7 @@ GNUNET_CRYPTO_kdf_v (void *result,
  * @param ... void * & size_t pairs for context chunks
  * @return #GNUNET_YES on success
  */
-int
+enum GNUNET_GenericReturnValue
 GNUNET_CRYPTO_kdf (void *result,
                    size_t out_len,
                    const void *xts,
@@ -145,6 +145,7 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
     uint8_t buf[ (nbits - 1) / 8 + 1 ];
     uint16_t ctr_nbo = htons (ctr);
 
+    memset (buf, 0, sizeof (buf));
     rc = GNUNET_CRYPTO_kdf (buf,
                             sizeof(buf),
                             xts, xts_len,
@@ -160,7 +161,7 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
                         sizeof(buf),
                         &rsize);
     GNUNET_assert (0 == rc);  /* Allocation error? */
-
+    GNUNET_assert (rsize == sizeof (buf));
     gcry_mpi_clear_highbit (*r, nbits);
     GNUNET_assert (0 == gcry_mpi_test_bit (*r, nbits));
     ++ctr;
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 43e6eedac..610e5febc 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -497,7 +497,8 @@ GNUNET_CRYPTO_rsa_public_key_decode (const char *buf,
  * @return True if gcd(r,n) = 1, False means RSA key is malicious
  */
 static int
-rsa_gcd_validate (gcry_mpi_t r, gcry_mpi_t n)
+rsa_gcd_validate (gcry_mpi_t r,
+                  gcry_mpi_t n)
 {
   gcry_mpi_t g;
   int t;
@@ -525,24 +526,29 @@ rsa_blinding_key_derive (const struct 
GNUNET_CRYPTO_RsaPublicKey *pkey,
   gcry_mpi_t n;
 
   blind = GNUNET_new (struct RsaBlindingKey);
-  GNUNET_assert (NULL != blind);
 
   /* Extract the composite n from the RSA public key */
-  GNUNET_assert (0 == key_from_sexp (&n, pkey->sexp, "rsa", "n"));
+  GNUNET_assert (0 ==
+                 key_from_sexp (&n,
+                                pkey->sexp,
+                                "rsa",
+                                "n"));
   /* Assert that it at least looks like an RSA key */
-  GNUNET_assert (0 == gcry_mpi_get_flag (n, GCRYMPI_FLAG_OPAQUE));
-
+  GNUNET_assert (0 ==
+                 gcry_mpi_get_flag (n,
+                                    GCRYMPI_FLAG_OPAQUE));
   GNUNET_CRYPTO_kdf_mod_mpi (&blind->r,
                              n,
                              xts, strlen (xts),
                              bks, sizeof(*bks),
                              "Blinding KDF");
-  if (0 == rsa_gcd_validate (blind->r, n))
+  if (0 == rsa_gcd_validate (blind->r,
+                             n))
   {
+    gcry_mpi_release (blind->r);
     GNUNET_free (blind);
     blind = NULL;
   }
-
   gcry_mpi_release (n);
   return blind;
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]