exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 80fe37fa7bc878941d011dfaa0e0547c6927ecf0
parent 7e435ae20b6bb232aba438797a3e93487f79a5b0
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 29 Jun 2026 23:34:43 +0200

avoid stack allocations that could be huge

Diffstat:
Msrc/auditor/taler-helper-auditor-reserves.c | 4++++
Msrc/bank-lib/bank_api_credit.c | 22++++++++++++++--------
Msrc/bank-lib/bank_api_debit.c | 6+++++-
Msrc/bank-lib/bank_api_registration.c | 6+++++-
4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c @@ -841,6 +841,10 @@ handle_recoup_by_reserve ( TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss), &TALER_ARL_USE_AB (reserves_total_bad_sig_loss), amount); + /* We continue here intentionally to credit the reserve anyway, + we already accounted for the loss, so we need to continue to + avoid getting another error when the reserve is drained which + would double-count the damage. */ } /* check that the coin was eligible for recoup!*/ diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c @@ -101,9 +101,11 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, } { size_t len = json_array_size (history_array); - struct TALER_BANK_CreditDetails cd[GNUNET_NZL (len)]; + struct TALER_BANK_CreditDetails *cd; GNUNET_break_op (0 != len); + cd = GNUNET_new_array (GNUNET_NZL (len), + struct TALER_BANK_CreditDetails); for (size_t i = 0; i<len; i++) { struct TALER_BANK_CreditDetails *td = &cd[i]; @@ -136,7 +138,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, NULL)) { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } if (no_credit_fee) { @@ -151,7 +153,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, &td->credit_fee)) { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } } if (0 == strcasecmp ("RESERVE", @@ -170,7 +172,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, NULL)) { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } td->type = TALER_BANK_CT_RESERVE; } @@ -190,7 +192,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, NULL)) { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } td->type = TALER_BANK_CT_KYCAUTH; } @@ -212,22 +214,26 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, NULL)) { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } td->type = TALER_BANK_CT_WAD; } else { GNUNET_break_op (0); - return GNUNET_SYSERR; + goto fail; } } chr.details.ok.details_length = len; chr.details.ok.details = cd; hh->hcb (hh->hcb_cls, &chr); + GNUNET_free (cd); + return GNUNET_OK; +fail: + GNUNET_free (cd); + return GNUNET_SYSERR; } - return GNUNET_OK; } diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c @@ -101,9 +101,11 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, } { size_t len = json_array_size (history_array); - struct TALER_BANK_DebitDetails dd[GNUNET_NZL (len)]; + struct TALER_BANK_DebitDetails *dd; GNUNET_break_op (0 != len); + dd = GNUNET_new_array (GNUNET_NZL (len), + struct TALER_BANK_DebitDetails); for (unsigned int i = 0; i<len; i++) { struct TALER_BANK_DebitDetails *td = &dd[i]; @@ -132,6 +134,7 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, NULL)) { GNUNET_break_op (0); + GNUNET_free (dd); return GNUNET_SYSERR; } } @@ -139,6 +142,7 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, dhr.details.ok.details = dd; hh->hcb (hh->hcb_cls, &dhr); + GNUNET_free (dd); } return GNUNET_OK; } diff --git a/src/bank-lib/bank_api_registration.c b/src/bank-lib/bank_api_registration.c @@ -215,10 +215,12 @@ handle_registration_finished (void *cls, { size_t n = json_array_size (subjects); - struct TALER_BANK_TransferSubject ts[GNUNET_NZL (n)]; + struct TALER_BANK_TransferSubject *ts; size_t i; const json_t *subject; + ts = GNUNET_new_array (GNUNET_NZL (n), + struct TALER_BANK_TransferSubject); json_array_foreach ((json_t *) subjects, i, subject) { if (GNUNET_OK != @@ -237,9 +239,11 @@ handle_registration_finished (void *cls, rr.details.ok.subjects = ts; rh->cb (rh->cb_cls, &rr); + GNUNET_free (ts); TALER_BANK_registration_cancel (rh); return; } + GNUNET_free (ts); } } break;