merchant

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

commit ccb3e0f161df4e3c5d60e177237384cc8f6b4b79
parent 0e1b08bf358424d397ece4e277e67d508ff73247
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 13 Feb 2022 14:54:51 +0100

-fix uninit nonce

Diffstat:
Msrc/lib/merchant_api_tip_pickup.c | 31+++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c @@ -103,6 +103,12 @@ struct TALER_MERCHANT_TipPickupHandle char *backend_url; /** + * Array of denomination keys and nonces, or NULL. + * Length is @e nks_len. + */ + struct TALER_EXCHANGE_NonceKey *nks; + + /** * ID of the tip we are picking up. */ struct TALER_TipIdentifierP tip_id; @@ -111,6 +117,11 @@ struct TALER_MERCHANT_TipPickupHandle * Number of planchets/coins used for this operation. */ unsigned int num_planchets; + + /** + * Length of the @e nks array. + */ + unsigned int nks_len; }; @@ -217,6 +228,7 @@ static void pickup_post_csr (struct TALER_MERCHANT_TipPickupHandle *tp) { struct TALER_PlanchetDetail details[tp->num_planchets]; + unsigned int noff = 0; for (unsigned int i = 0; i<tp->num_planchets; i++) { @@ -229,6 +241,13 @@ pickup_post_csr (struct TALER_MERCHANT_TipPickupHandle *tp) TALER_planchet_blinding_secret_create (&pd->ps, &pcd->exchange_vals, &pcd->bks); + if (TALER_DENOMINATION_CS == pcd->exchange_vals.cipher) + { + GNUNET_assert (noff < tp->nks_len); + details[i].blinded_planchet.details.cs_blinded_planchet.nonce + = tp->nks[noff].nonce; + noff++; + } if (GNUNET_OK != TALER_planchet_prepare (&pd->pk.key, &pcd->exchange_vals, @@ -392,13 +411,16 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx, pickup_post_csr (tp); return tp; } + tp->nks_len = num_csr; + tp->nks = GNUNET_new_array (num_csr, + struct TALER_EXCHANGE_NonceKey); { - struct TALER_EXCHANGE_NonceKey nks[num_csr]; unsigned int off = 0; for (unsigned int i = 0; i<tp->num_planchets; i++) { const struct PlanchetData *pd = &tp->planchets[i]; + struct TALER_EXCHANGE_NonceKey *nk = &tp->nks[i]; switch (pd->pk.key.cipher) { @@ -408,16 +430,16 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx, case TALER_DENOMINATION_RSA: break; case TALER_DENOMINATION_CS: - nks[off].pk = &pd->pk; + nk->pk = &pd->pk; TALER_cs_withdraw_nonce_derive (&pd->ps, - &nks[off].nonce); + &nk->nonce); off++; break; } } tp->csr = TALER_EXCHANGE_csr (exchange, off, - nks, + tp->nks, &csr_cb, tp); if (NULL == tp->csr) @@ -455,6 +477,7 @@ TALER_MERCHANT_tip_pickup_cancel (struct TALER_MERCHANT_TipPickupHandle *tp) tp->csr = NULL; } GNUNET_free (tp->backend_url); + GNUNET_free (tp->nks); GNUNET_free (tp->pcds); GNUNET_free (tp); }