merchant

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

commit c9a7d33aad0e084b07b811bb97ee4bd292bf8986
parent c11931eba21ec6ce522b103d25d26342c886581d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  9 Oct 2026 22:47:13 +0200

improve input validation for donations

Diffstat:
Msrc/backend/taler-merchant-httpd_post-orders-ORDER_ID-pay.c | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 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 @@ -4021,7 +4021,25 @@ handle_output_donation_receipt ( const struct TALER_MERCHANT_ContractOutput *output) { enum GNUNET_GenericReturnValue ret; + bool listed = false; + for (unsigned int i = 0; + i < output->details.donation_receipt.donau_urls_len; + i++) + if (0 == strcmp (output->details.donation_receipt.donau_urls[i], + pc->parse_wallet_data.donau.donau_url)) + listed = true; + if (! listed) + { + GNUNET_break_op (0); + pay_end (pc, + TALER_MHD_reply_with_error ( + pc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "donau URL not accepted by contract")); + return GNUNET_NO; + } ret = DONAU_get_donation_amount_from_bkps ( pc->parse_wallet_data.donau_keys, pc->parse_wallet_data.bkps, @@ -4366,6 +4384,21 @@ phase_validate_tokens (struct PayContext *pc) break; } /* switch on contract type */ + if ( (0 != pc->parse_wallet_data.num_bkps) && + (pc->validate_tokens.donau_output_index < 0) ) + { + /* We must not have the charity issue receipts for a choice + that does not include a donation. */ + GNUNET_break_op (0); + pay_end (pc, + TALER_MHD_reply_with_error ( + pc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "donation receipts requested, but choice has no donation output")); + return; + } + for (size_t i = 0; i<pc->parse_pay.coins_cnt; i++) { const struct DepositConfirmation *dc = &pc->parse_pay.dc[i];