summaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_tip_pickup.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-13 14:54:51 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-13 14:54:51 +0100
commitccb3e0f161df4e3c5d60e177237384cc8f6b4b79 (patch)
tree7d018e4b8ab598f7af656846e29fbead3cf74489 /src/lib/merchant_api_tip_pickup.c
parent0e1b08bf358424d397ece4e277e67d508ff73247 (diff)
downloadmerchant-ccb3e0f161df4e3c5d60e177237384cc8f6b4b79.tar.gz
merchant-ccb3e0f161df4e3c5d60e177237384cc8f6b4b79.tar.bz2
merchant-ccb3e0f161df4e3c5d60e177237384cc8f6b4b79.zip
-fix uninit nonce
Diffstat (limited to 'src/lib/merchant_api_tip_pickup.c')
-rw-r--r--src/lib/merchant_api_tip_pickup.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c
index 9ed9afa1..8118918b 100644
--- 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);
}