gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] 02/02: fix potential free of uninitialized


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 02/02: fix potential free of uninitialized ptr, (on virtually impossible error handling path)
Date: Mon, 03 Jun 2019 11:17:45 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

commit 91ef87a804d34f535ef97b6caa7fbd6c327550e8
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jun 3 11:17:29 2019 +0200

    fix potential free of uninitialized ptr, (on virtually impossible error 
handling path)
---
 src/lib/exchange_api_refresh.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c
index ec9c1d99..e2a3a245 100644
--- a/src/lib/exchange_api_refresh.c
+++ b/src/lib/exchange_api_refresh.c
@@ -246,7 +246,7 @@ free_melt_data (struct MeltData *md)
   }
 
   for (unsigned int i=0;i<TALER_CNC_KAPPA;i++)
-    GNUNET_free (md->fresh_coins[i]);
+    GNUNET_free_non_null (md->fresh_coins[i]);
   /* Finally, clean up a bit...
      (NOTE: compilers might optimize this away, so this is
      not providing any strong assurances that the key material
@@ -705,6 +705,7 @@ TALER_EXCHANGE_refresh_prepare (const struct 
TALER_CoinSpendPrivateKeyP *melt_pr
   GNUNET_CRYPTO_eddsa_key_get_public (&melt_priv->eddsa_priv,
                                       &coin_pub.eddsa_pub);
   /* build up melt data structure */
+  memset (&md, 0, sizeof (md));
   md.num_fresh_coins = fresh_pks_len;
   md.melted_coin.coin_priv = *melt_priv;
   md.melted_coin.melt_amount_with_fee = *melt_amount;
@@ -713,8 +714,8 @@ TALER_EXCHANGE_refresh_prepare (const struct 
TALER_CoinSpendPrivateKeyP *melt_pr
   md.melted_coin.expire_deposit
     = melt_pk->expire_deposit;
   GNUNET_assert (GNUNET_OK ==
-                TALER_amount_get_zero (melt_amount->currency,
-                                       &total));
+                 TALER_amount_get_zero (melt_amount->currency,
+                                        &total));
   md.melted_coin.pub_key.rsa_public_key
     = GNUNET_CRYPTO_rsa_public_key_dup (melt_pk->key.rsa_public_key);
   md.melted_coin.sig.rsa_signature
@@ -726,13 +727,13 @@ TALER_EXCHANGE_refresh_prepare (const struct 
TALER_CoinSpendPrivateKeyP *melt_pr
     md.fresh_pks[i].rsa_public_key
       = GNUNET_CRYPTO_rsa_public_key_dup (fresh_pks[i].key.rsa_public_key);
     if ( (GNUNET_OK !=
-         TALER_amount_add (&total,
-                           &total,
-                           &fresh_pks[i].value)) ||
-        (GNUNET_OK !=
-         TALER_amount_add (&total,
-                           &total,
-                           &fresh_pks[i].fee_withdraw)) )
+          TALER_amount_add (&total,
+                            &total,
+                            &fresh_pks[i].value)) ||
+         (GNUNET_OK !=
+          TALER_amount_add (&total,
+                            &total,
+                            &fresh_pks[i].fee_withdraw)) )
     {
       GNUNET_break (0);
       free_melt_data (&md);
@@ -742,7 +743,7 @@ TALER_EXCHANGE_refresh_prepare (const struct 
TALER_CoinSpendPrivateKeyP *melt_pr
   /* verify that melt_amount is above total cost */
   if (1 ==
       TALER_amount_cmp (&total,
-                       melt_amount) )
+                        melt_amount) )
   {
     /* Eh, this operation is more expensive than the
        @a melt_amount. This is not OK. */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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