From 91ef87a804d34f535ef97b6caa7fbd6c327550e8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 3 Jun 2019 11:17:29 +0200 Subject: 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(-) (limited to 'src/lib/exchange_api_refresh.c') diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c index ec9c1d992..e2a3a245a 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;ifresh_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. */ -- cgit v1.2.3