From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 18 Nov 2026 17:41:26 +0100 Subject: [PATCH] testing: keep tax receipts out of the pay command's issued tokens With a tax-receipt output before a token output, the token slots were indexed past the end of the grown array. Issue: https://bugs.taler.net/n/12209 Assisted by LLM --- src/testing/testing_api_cmd_pay_order.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index 9b041889..568bf900 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -468,10 +468,18 @@ struct PayState unsigned int num_issued_tokens; /** - * Number of donau_tokens in @e issued_tokens. + * Number of Donau receipts we expect in the token signatures + * of the response (NOT stored in @e issued_tokens). */ unsigned int num_donau_tokens; + /** + * Position of the first Donau receipt signature in the token + * signatures of the response, i.e. the number of entries of + * @e issued_tokens that come from outputs before the tax receipt. + */ + unsigned int donau_sig_offset; + /** * The session for which the payment is made. */ @@ -850,8 +858,13 @@ pay_cb (struct PayState *ps, &ps->issued_tokens[i]; /* The issued tokens should be in the - same order as the provided envelopes. */ - ps->issued_tokens[i].blinded_sig = pr->details.ok.tokens[i].blinded_sig; + same order as the provided envelopes; the Donau + receipts sit at the position of the tax-receipt output. */ + unsigned int j = (i < ps->donau_sig_offset) + ? i + : i + ps->num_donau_tokens; + + ps->issued_tokens[i].blinded_sig = pr->details.ok.tokens[j].blinded_sig; if (GNUNET_OK != TALER_token_issue_sig_unblind (&details->issue_sig, @@ -1274,6 +1287,7 @@ pay_run (void *cls, return; } ps->num_donau_tokens = ps->donau_data.num_bkps; + ps->donau_sig_offset = ps->num_issued_tokens; } } } @@ -1317,13 +1331,12 @@ pay_run (void *cls, GNUNET_array_grow ( ps->issued_tokens, ps->num_issued_tokens, - ps->num_issued_tokens + count + ps->num_donau_tokens); + ps->num_issued_tokens + count); for (unsigned int k = 0; k < count; k++) { struct TALER_MERCHANT_PrivateTokenDetails *details = - &ps->issued_tokens[ps->num_issued_tokens - count + k - + ps->num_donau_tokens]; + &ps->issued_tokens[ps->num_issued_tokens - count + k]; if (GNUNET_OK != find_token_public_key (token_families, -- 2.47.3