aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2024-01-12 11:56:55 +0100
committerÖzgür Kesim <oec-taler@kesim.org>2024-01-12 11:56:55 +0100
commita6b35ee7d345aa11e0388733fb95f3a4d2e52180 (patch)
tree6b33d6265092df3d2bc92b82bfa83f71e2863979
parent395a4c5fef631274f6cd13be697ef62ebc49546a (diff)
fixes for #8069, #8070 and #8072
- TALER_coin_ev_hash function now returns void - double free fixes - FAIL_IF logic fixes
-rw-r--r--src/exchange/taler-exchange-httpd_age-withdraw.c8
-rw-r--r--src/exchange/taler-exchange-httpd_age-withdraw_reveal.c9
-rw-r--r--src/exchange/taler-exchange-httpd_batch-withdraw.c15
-rw-r--r--src/exchange/taler-exchange-httpd_recoup.c14
-rw-r--r--src/exchangedb/perf_deposits_get_ready.c22
-rw-r--r--src/exchangedb/perf_select_refunds_by_coin.c22
-rw-r--r--src/include/taler_crypto_lib.h21
-rw-r--r--src/lib/exchange_api_age_withdraw.c74
-rw-r--r--src/lib/exchange_api_age_withdraw_reveal.c24
-rw-r--r--src/lib/exchange_api_batch_withdraw2.c13
-rw-r--r--src/testing/testing_api_cmd_age_withdraw.c5
-rw-r--r--src/util/crypto.c3
12 files changed, 104 insertions, 126 deletions
diff --git a/src/exchange/taler-exchange-httpd_age-withdraw.c b/src/exchange/taler-exchange-httpd_age-withdraw.c
index 939e0f76d..9276fb191 100644
--- a/src/exchange/taler-exchange-httpd_age-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_age-withdraw.c
@@ -225,7 +225,6 @@ parse_age_withdraw_json (
* the commitment along the way. */
{
unsigned int kappa = 0;
- enum GNUNET_GenericReturnValue ret;
json_array_foreach (j_kappa_coin_evs, kappa, value) {
struct GNUNET_JSON_Specification spec[] = {
@@ -253,10 +252,9 @@ parse_age_withdraw_json (
{
struct TALER_BlindedCoinHashP bch;
- ret = TALER_coin_ev_hash (&awc->coin_evs[idx][kappa],
- &awc->denom_hs[idx],
- &bch);
- GNUNET_assert (GNUNET_OK == ret);
+ TALER_coin_ev_hash (&awc->coin_evs[idx][kappa],
+ &awc->denom_hs[idx],
+ &bch);
GNUNET_CRYPTO_hash_context_read (hash_context,
&bch,
sizeof(bch));
diff --git a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c
index 632368ded..c9aca8e99 100644
--- a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c
+++ b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c
@@ -357,11 +357,10 @@ calculate_blinded_hash (
return ret;
}
- ret = TALER_coin_ev_hash (&detail.blinded_planchet,
- &denom_key->h_denom_pub,
- bch);
+ TALER_coin_ev_hash (&detail.blinded_planchet,
+ &denom_key->h_denom_pub,
+ bch);
TALER_blinded_planchet_free (&detail.blinded_planchet);
- GNUNET_assert (GNUNET_OK == ret);
}
return ret;
@@ -594,7 +593,7 @@ TEH_handler_age_withdraw_reveal (
result = reply_age_withdraw_reveal_success (rc->connection,
&actx.commitment);
- } while(0);
+ } while (0);
GNUNET_JSON_parse_free (spec);
if (NULL != actx.commitment.denom_sigs)
diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c
index e296f31f8..2b80c2fc4 100644
--- a/src/exchange/taler-exchange-httpd_batch-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -838,17 +838,10 @@ parse_planchets (const struct TEH_RequestContext *rc,
NULL);
}
- if (GNUNET_OK !=
- TALER_coin_ev_hash (&pc->blinded_planchet,
- &pc->collectable.denom_pub_hash,
- &pc->collectable.h_coin_envelope))
- {
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (rc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- NULL);
- }
+ TALER_coin_ev_hash (&pc->blinded_planchet,
+ &pc->collectable.denom_pub_hash,
+ &pc->collectable.h_coin_envelope);
+
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_withdraw_verify (&pc->collectable.denom_pub_hash,
diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c
index 6173ca6c9..afbbd7474 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -284,17 +284,9 @@ verify_and_execute_recoup (
TALER_EC_EXCHANGE_RECOUP_BLINDING_FAILED,
NULL);
}
- if (GNUNET_OK !=
- TALER_coin_ev_hash (&blinded_planchet,
- &coin->denom_pub_hash,
- &pc.h_coin_ev))
- {
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- NULL);
- }
+ TALER_coin_ev_hash (&blinded_planchet,
+ &coin->denom_pub_hash,
+ &pc.h_coin_ev);
TALER_blinded_planchet_free (&blinded_planchet);
}
diff --git a/src/exchangedb/perf_deposits_get_ready.c b/src/exchangedb/perf_deposits_get_ready.c
index cba751e15..005ea6843 100644
--- a/src/exchangedb/perf_deposits_get_ready.c
+++ b/src/exchangedb/perf_deposits_get_ready.c
@@ -33,24 +33,25 @@ static int result;
* Report line of error if @a cond is true, and jump to label "drop".
*/
#define FAILIF(cond) \
- do { \
- if (! (cond)) {break;} \
- GNUNET_break (0); \
- goto drop; \
- } while (0)
+ do { \
+ if (! (cond)) {break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
/**
* Initializes @a ptr with random data.
*/
#define RND_BLK(ptr) \
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, \
+ sizeof (*ptr))
/**
* Initializes @a ptr with zeros.
*/
#define ZR_BLK(ptr) \
- memset (ptr, 0, sizeof (*ptr))
+ memset (ptr, 0, sizeof (*ptr))
/**
* Currency we use. Must match test-exchange-db-*.conf.
@@ -300,10 +301,9 @@ run (void *cls)
&new_dkp[cnt]->priv,
true,
bp));
- GNUNET_assert (GNUNET_OK ==
- TALER_coin_ev_hash (bp,
- &cbc.denom_pub_hash,
- &cbc.h_coin_envelope));
+ TALER_coin_ev_hash (bp,
+ &cbc.denom_pub_hash,
+ &cbc.h_coin_envelope);
GNUNET_assert (
GNUNET_OK ==
TALER_denom_sign_blinded (
diff --git a/src/exchangedb/perf_select_refunds_by_coin.c b/src/exchangedb/perf_select_refunds_by_coin.c
index 8f2946fb8..84825d6d7 100644
--- a/src/exchangedb/perf_select_refunds_by_coin.c
+++ b/src/exchangedb/perf_select_refunds_by_coin.c
@@ -33,23 +33,24 @@ static int result;
* Report line of error if @a cond is true, and jump to label "drop".
*/
#define FAILIF(cond) \
- do { \
- if (! (cond)) {break;} \
- GNUNET_break (0); \
- goto drop; \
- } while (0)
+ do { \
+ if (! (cond)) {break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
/**
* Initializes @a ptr with random data.
*/
#define RND_BLK(ptr) \
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, \
+ sizeof (*ptr))
/**
* Initializes @a ptr with zeros.
*/
#define ZR_BLK(ptr) \
- memset (ptr, 0, sizeof (*ptr))
+ memset (ptr, 0, sizeof (*ptr))
/**
* Currency we use. Must match test-exchange-db-*.conf.
@@ -325,10 +326,9 @@ run (void *cls)
&new_dkp[cnt]->priv,
true,
bp));
- GNUNET_assert (GNUNET_OK ==
- TALER_coin_ev_hash (bp,
- &cbc.denom_pub_hash,
- &cbc.h_coin_envelope));
+ TALER_coin_ev_hash (bp,
+ &cbc.denom_pub_hash,
+ &cbc.h_coin_envelope);
GNUNET_assert (
GNUNET_OK ==
TALER_denom_sign_blinded (
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 4cc05c5ce..9e074a0c4 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1719,9 +1719,8 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info,
* @param blinded_planchet blinded planchet
* @param denom_hash hash of the denomination public key
* @param[out] bch where to write the hash
- * @return #GNUNET_OK when successful, #GNUNET_SYSERR if an internal error occurred
*/
-enum GNUNET_GenericReturnValue
+void
TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
const struct TALER_DenominationHashP *denom_hash,
struct TALER_BlindedCoinHashP *bch);
@@ -2805,15 +2804,15 @@ TALER_CRYPTO_helper_esign_sign_ (
* @return the error code (or #TALER_EC_NONE on success)
*/
#define TALER_CRYPTO_helper_esign_sign(esh,ps,epub,esig) ( \
- /* check size is set correctly */ \
- GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)), \
- /* check 'ps' begins with the purpose */ \
- GNUNET_static_assert (((void*) (ps)) == \
- ((void*) &(ps)->purpose)), \
- TALER_CRYPTO_helper_esign_sign_ (esh, \
- &(ps)->purpose, \
- epub, \
- esig) )
+ /* check size is set correctly */ \
+ GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)), \
+ /* check 'ps' begins with the purpose */ \
+ GNUNET_static_assert (((void*) (ps)) == \
+ ((void*) &(ps)->purpose)), \
+ TALER_CRYPTO_helper_esign_sign_ (esh, \
+ &(ps)->purpose, \
+ epub, \
+ esig) )
/**
diff --git a/src/lib/exchange_api_age_withdraw.c b/src/lib/exchange_api_age_withdraw.c
index e319332d1..8f8d2b2b0 100644
--- a/src/lib/exchange_api_age_withdraw.c
+++ b/src/lib/exchange_api_age_withdraw.c
@@ -500,15 +500,15 @@ perform_protocol (
struct TALER_EXCHANGE_AgeWithdrawBlindedHandle *awbh)
{
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto ERROR; \
- } \
- } while(0)
-
- struct GNUNET_HashContext *coins_hctx;
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto ERROR; \
+ } \
+ } while (0)
+
+ struct GNUNET_HashContext *coins_hctx = NULL;
json_t *j_denoms = NULL;
json_t *j_array_candidates = NULL;
json_t *j_request_body = NULL;
@@ -567,7 +567,7 @@ perform_protocol (
GNUNET_JSON_pack_data_auto (NULL,
denom_h));
FAIL_IF (NULL == jdenom);
- FAIL_IF (0 < json_array_append_new (j_denoms,
+ FAIL_IF (0 > json_array_append_new (j_denoms,
jdenom));
/* Build the candidate array */
@@ -586,7 +586,7 @@ perform_protocol (
&planchet->blinded_planchet));
FAIL_IF (NULL == jc);
- FAIL_IF (0 < json_array_append_new (j_can,
+ FAIL_IF (0 > json_array_append_new (j_can,
jc));
TALER_coin_ev_hash (&planchet->blinded_planchet,
@@ -598,7 +598,7 @@ perform_protocol (
sizeof(bch));
}
- FAIL_IF (0 < json_array_append_new (j_array_candidates,
+ FAIL_IF (0 > json_array_append_new (j_array_candidates,
j_can));
}
}
@@ -607,6 +607,7 @@ perform_protocol (
/* Build the hash of the commitment */
GNUNET_CRYPTO_hash_context_finish (coins_hctx,
&awbh->h_commitment.hash);
+ coins_hctx = NULL;
/* Sign the request */
TALER_wallet_age_withdraw_sign (&awbh->h_commitment,
@@ -653,6 +654,8 @@ ERROR:
json_decref (j_request_body);
if (NULL != curlh)
curl_easy_cleanup (curlh);
+ if (NULL != coins_hctx)
+ GNUNET_CRYPTO_hash_context_abort (coins_hctx);
TALER_EXCHANGE_age_withdraw_blinded_cancel (awbh);
return;
#undef FAIL_IF
@@ -685,12 +688,8 @@ copy_results (
.num_coins = awh->num_coins,
.coin_details = details,
.blinded_coin_hs = blinded_coin_hs
- }
-
-
- }
-
-
+ },
+ },
};
for (size_t n = 0; n< awh->num_coins; n++)
@@ -838,21 +837,14 @@ csr_withdraw_done (
planchet))
{
GNUNET_break (0);
- TALER_EXCHANGE_age_withdraw_cancel (awh);
break;
}
- if (GNUNET_OK !=
- TALER_coin_ev_hash (&planchet->blinded_planchet,
- &planchet->denom_pub_hash,
- &can->blinded_coin_h))
- {
- GNUNET_break (0);
- TALER_EXCHANGE_age_withdraw_cancel (awh);
- break;
- }
+ TALER_coin_ev_hash (&planchet->blinded_planchet,
+ &planchet->denom_pub_hash,
+ &can->blinded_coin_h);
success = true;
- } while(0);
+ } while (0);
awh->csr.pending--;
@@ -890,13 +882,13 @@ prepare_coins (
static num_coins])
{
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto ERROR; \
- } \
- } while(0)
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto ERROR; \
+ } \
+ } while (0)
GNUNET_assert (0 < num_coins);
awh->age_mask = coin_inputs[0].denom_pub->key.age_mask;
@@ -952,10 +944,9 @@ prepare_coins (
&can->details.h_age_commitment,
&can->details.h_coin_pub,
planchet));
- FAIL_IF (GNUNET_OK !=
- TALER_coin_ev_hash (&planchet->blinded_planchet,
- &planchet->denom_pub_hash,
- &can->blinded_coin_h));
+ TALER_coin_ev_hash (&planchet->blinded_planchet,
+ &planchet->denom_pub_hash,
+ &can->blinded_coin_h);
break;
case GNUNET_CRYPTO_BSA_CS:
{
@@ -1025,7 +1016,10 @@ TALER_EXCHANGE_age_withdraw (
if (GNUNET_OK != prepare_coins (awh,
num_coins,
coin_inputs))
+ {
+ GNUNET_free (awh);
return NULL;
+ }
/* If there were no CS denominations, we can now perform the actual
* age-withdraw protocol. Otherwise, there are calls to /csr-withdraw
diff --git a/src/lib/exchange_api_age_withdraw_reveal.c b/src/lib/exchange_api_age_withdraw_reveal.c
index a448d109d..cade528d2 100644
--- a/src/lib/exchange_api_age_withdraw_reveal.c
+++ b/src/lib/exchange_api_age_withdraw_reveal.c
@@ -57,7 +57,7 @@ struct TALER_EXCHANGE_AgeWithdrawRevealHandle
const struct TALER_EXCHANGE_AgeWithdrawCoinInput *coins_input;
/* The url for the reveal request */
- const char *request_url;
+ char *request_url;
/**
* CURL handle for the request job.
@@ -146,6 +146,9 @@ age_withdraw_reveal_ok (
&response);
/* Make sure the callback isn't called again */
awrh->callback = NULL;
+ /* Free resources */
+ for (size_t i = 0; i < awrh->num_coins; i++)
+ TALER_blinded_denom_sig_free (&denom_sigs[i]);
}
return GNUNET_OK;
@@ -340,13 +343,13 @@ perform_protocol (
json_t *j_sec = NULL;
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto ERROR; \
- } \
- } while(0)
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto ERROR; \
+ } \
+ } while (0)
j_array_of_secrets = json_array ();
FAIL_IF (NULL == j_array_of_secrets);
@@ -463,7 +466,10 @@ TALER_EXCHANGE_age_withdraw_reveal_cancel (
awrh->job = NULL;
}
TALER_curl_easy_post_finished (&awrh->post_ctx);
- /* FIXME[oec]: anything else left to cleanup!? */
+
+ if (NULL != awrh->request_url)
+ GNUNET_free (awrh->request_url);
+
GNUNET_free (awrh);
}
diff --git a/src/lib/exchange_api_batch_withdraw2.c b/src/lib/exchange_api_batch_withdraw2.c
index b6f773197..453d8a0ab 100644
--- a/src/lib/exchange_api_batch_withdraw2.c
+++ b/src/lib/exchange_api_batch_withdraw2.c
@@ -373,16 +373,9 @@ TALER_EXCHANGE_batch_withdraw2 (
json_decref (jc);
return NULL;
}
- if (GNUNET_OK !=
- TALER_coin_ev_hash (&pd->blinded_planchet,
- &pd->denom_pub_hash,
- &bch))
- {
- GNUNET_break (0);
- TALER_EXCHANGE_batch_withdraw2_cancel (wh);
- json_decref (jc);
- return NULL;
- }
+ TALER_coin_ev_hash (&pd->blinded_planchet,
+ &pd->denom_pub_hash,
+ &bch);
TALER_wallet_withdraw_sign (&pd->denom_pub_hash,
&coin_total,
&bch,
diff --git a/src/testing/testing_api_cmd_age_withdraw.c b/src/testing/testing_api_cmd_age_withdraw.c
index 30f409f4a..6ad22809e 100644
--- a/src/testing/testing_api_cmd_age_withdraw.c
+++ b/src/testing/testing_api_cmd_age_withdraw.c
@@ -585,6 +585,7 @@ age_withdraw_reveal_cb (
awrs->denom_sigs = GNUNET_new_array (awrs->num_coins,
struct TALER_DenominationSignature);
for (size_t n = 0; n < awrs->num_coins; n++)
+ {
GNUNET_assert (GNUNET_OK ==
TALER_denom_sig_unblind (
&awrs->denom_sigs[n],
@@ -593,8 +594,12 @@ age_withdraw_reveal_cb (
&aws->coin_outputs[n].details.h_coin_pub,
&aws->coin_outputs[n].details.alg_values,
&aws->coin_inputs[n].denom_pub->key));
+ TALER_denom_sig_free (&awrs->denom_sigs[n]);
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"age-withdraw reveal success!\n");
+ GNUNET_free (awrs->denom_sigs);
}
break;
case MHD_HTTP_NOT_FOUND:
diff --git a/src/util/crypto.c b/src/util/crypto.c
index d8c6d7912..4735af3b0 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -473,7 +473,7 @@ TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub,
}
-enum GNUNET_GenericReturnValue
+void
TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
const struct TALER_DenominationHashP *denom_hash,
struct TALER_BlindedCoinHashP *bch)
@@ -488,7 +488,6 @@ TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
hash_context);
GNUNET_CRYPTO_hash_context_finish (hash_context,
&bch->hash);
- return GNUNET_OK;
}