diff options
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 |
commit | a6b35ee7d345aa11e0388733fb95f3a4d2e52180 (patch) | |
tree | 6b33d6265092df3d2bc92b82bfa83f71e2863979 /src/lib | |
parent | 395a4c5fef631274f6cd13be697ef62ebc49546a (diff) | |
download | exchange-a6b35ee7d345aa11e0388733fb95f3a4d2e52180.tar.gz exchange-a6b35ee7d345aa11e0388733fb95f3a4d2e52180.tar.bz2 exchange-a6b35ee7d345aa11e0388733fb95f3a4d2e52180.zip |
fixes for #8069, #8070 and #8072
- TALER_coin_ev_hash function now returns void
- double free fixes
- FAIL_IF logic fixes
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/exchange_api_age_withdraw.c | 74 | ||||
-rw-r--r-- | src/lib/exchange_api_age_withdraw_reveal.c | 24 | ||||
-rw-r--r-- | src/lib/exchange_api_batch_withdraw2.c | 13 |
3 files changed, 52 insertions, 59 deletions
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, |