merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit ce8fb69687e3903065a8880f4f8df761ea1993a1
parent add1b5862a2b1f0719bfa1ad04337dffdbd48eca
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 29 Jun 2026 00:17:54 +0200

compute input token index correctly

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ORDER_ID-pay.c | 24++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ORDER_ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ORDER_ID-pay.c @@ -3296,7 +3296,8 @@ phase_execute_pay_transaction (struct PayContext *pc) * * @param[in,out] pc payment context we are processing * @param family family the tokens should be from - * @param index number of the input we are handling + * @param index offset into parse_pay.tokens where the + * input tokens for @a family should start * @param expected_num number of tokens expected * @return #GNUNET_YES on success */ @@ -3318,6 +3319,20 @@ find_valid_input_tokens ( = &pc->parse_pay.tokens[index + j]; const struct TALER_MERCHANT_ContractTokenFamilyKey *key = NULL; + if (index + j > pc->parse_pay.tokens_cnt) + { + /* There are not a sufficient number of input tokens left + to satisfy the request. Game over. */ + GNUNET_break_op (0); + pay_end (pc, + TALER_MHD_reply_with_error ( + pc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_TOKEN_COUNT_MISMATCH, + NULL)); + return GNUNET_NO; + } + for (unsigned int i = 0; i<family->keys_len; i++) { const struct TALER_MERCHANT_ContractTokenFamilyKey *ki @@ -3436,7 +3451,7 @@ find_valid_input_tokens ( expected_num, family->slug, num_validated); - GNUNET_break (0); + GNUNET_break_op (0); pay_end (pc, TALER_MHD_reply_with_error ( pc->connection, @@ -3940,7 +3955,7 @@ phase_validate_tokens (struct PayContext *pc) pc->validate_tokens.max_fee = selected->max_fee; pc->validate_tokens.brutto = selected->amount; - + wallet_off = 0; for (unsigned int i = 0; i<selected->inputs_len; i++) { const struct TALER_MERCHANT_ContractInput *input @@ -3988,12 +4003,13 @@ phase_validate_tokens (struct PayContext *pc) if (GNUNET_NO == find_valid_input_tokens (pc, family, - i, + wallet_off, input->details.token.count)) { /* Error is already scheduled from find_valid_input_token. */ return; } + wallet_off += input->details.token.count; } }