View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012209 | Taler | merchant backend | public | 2026-11-18 16:41 | 2026-11-18 16:41 |
| Reporter | bot-cg [agent] | ||||
| Priority | normal | Severity | minor | ||
| Status | new | ||||
| Product Version | git (master) | ||||
| Summary | 0012209: testing_api_cmd_pay_order writes past issued_tokens when a tax-receipt output comes before a token output | ||||
| Description | pay_run() (src/testing/testing_api_cmd_pay_order.c) sets num_donau_tokens = D for a tax-receipt output, then for each later token output grows issued_tokens from N to N + count + D and writes entry k at index (N + count + D) - count + k + D = N + k + 2D. For D > 0 that is up to D entries past the end of the array. pay_cb() also maps the reply's token signatures to issued_tokens one by one, without skipping the receipts, which sit at the position of the tax-receipt output. Test code only, and no current test uses this output order. Confirmed by reading the code at 495a791d. The attached patch grows the array by count only, keeps the receipts out of issued_tokens, and records where they start so that pay_cb() skips their signatures. | ||||
| Additional Information | Recorded as H2 in the merchant review notes; the patch is that review's 1604. | ||||
| Tags | No tags attached. | ||||
| Attached Files | 12209-testing-keep-tax-receipts-out-of-the-pay-command-s-i.patch (2,997 bytes)
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
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
| ||||
| child of | 0012186 | new | Unchecked array lengths and counts in exchange, merchant and anastasis: review after 2a57cbcaf [meta] |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-18 16:41 | bot-cg | New Issue | |
| 2026-11-18 16:41 | bot-cg | Relationship added | child of 0012186 |
| 2026-11-18 16:41 | bot-cg | Implementer | => Bohdan |
| 2026-11-18 16:41 | bot-cg | Reviewer | => sebasjm |
| 2026-11-18 16:41 | bot-cg | Release signed by | => Florian Dold |
| 2026-11-18 16:41 | bot-cg | Deployed by | => Bohdan |
| 2026-11-18 16:41 | bot-cg | Verifier | => sebasjm |
| 2026-11-18 16:41 | bot-cg | Communicator | => CM_7 |
| 2026-11-18 16:41 | bot-cg | File Added: 12209-testing-keep-tax-receipts-out-of-the-pay-command-s-i.patch |