commit 9ace9084f2830fadb913a8b18a525f0361c05565
parent 5d5edb9aebaf229be5e9c7ab947065307ded1205
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 27 Mar 2025 15:25:04 +0100
fix misc minor bugs, compiler warnings and one moderate bug (confusion of idx and err_idx)
Diffstat:
11 files changed, 55 insertions(+), 60 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
@@ -763,7 +763,7 @@ handle_post_reserves (struct TEH_RequestContext *rc,
} h[] = {
{
- /* FIXME: deprecated since v24 */
+ /* deprecated since v26 */
.op = "batch-withdraw",
.handler = &TEH_handler_batch_withdraw
},
diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -18,7 +18,7 @@
*/
/*
- * NOTE: These endpoints are deprecated starting with v24 of the protocol and will be removed,
+ * NOTE: These endpoints are deprecated starting with v26 of the protocol and will be removed,
* including this file.
*/
diff --git a/src/exchange/taler-exchange-httpd_blinding-prepare.c b/src/exchange/taler-exchange-httpd_blinding-prepare.c
@@ -94,10 +94,8 @@ TEH_handler_blinding_prepare (struct TEH_RequestContext *rc,
{
struct GNUNET_CRYPTO_CsSessionNonce nonces[num];
struct TALER_DenominationHashP h_denom_pubs[num];
- size_t idx;
-
- for (idx = 0; idx < num; idx++)
+ for (size_t idx = 0; idx < num; idx++)
{
struct GNUNET_JSON_Specification denom_spec[] = {
GNUNET_JSON_spec_fixed_auto (NULL,
@@ -117,15 +115,18 @@ TEH_handler_blinding_prepare (struct TEH_RequestContext *rc,
idx,
-1);
if (GNUNET_OK != res)
- return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
-
+ return (GNUNET_SYSERR == res)
+ ? MHD_NO
+ : MHD_YES;
res = TALER_MHD_parse_json_array (rc->connection,
j_nonces,
nonce_spec,
idx,
-1);
if (GNUNET_OK != res)
- return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
+ return (GNUNET_SYSERR == res)
+ ? MHD_NO
+ : MHD_YES;
}
{
@@ -141,7 +142,7 @@ TEH_handler_blinding_prepare (struct TEH_RequestContext *rc,
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
NULL);
- ec =
+ ec =
TEH_keys_denomination_cs_batch_r_pub (ksh,
num,
h_denom_pubs,
@@ -153,35 +154,30 @@ TEH_handler_blinding_prepare (struct TEH_RequestContext *rc,
{
case TALER_EC_NONE:
break;
-
case TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN:
return TEH_RESPONSE_reply_unknown_denom_pub_hash (
rc->connection,
- &h_denom_pubs[idx]);
+ &h_denom_pubs[err_idx]);
break;
-
case TALER_EC_EXCHANGE_GENERIC_INVALID_DENOMINATION_CIPHER_FOR_OPERATION:
return TEH_RESPONSE_reply_invalid_denom_cipher_for_operation (
rc->connection,
- &h_denom_pubs[idx]);
+ &h_denom_pubs[err_idx]);
break;
-
case TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED:
return TEH_RESPONSE_reply_expired_denom_pub_hash (
rc->connection,
- &h_denom_pubs[idx],
+ &h_denom_pubs[err_idx],
ec,
"blinding-prepare");
break;
-
case TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE:
return TEH_RESPONSE_reply_expired_denom_pub_hash (
rc->connection,
- &h_denom_pubs[idx],
+ &h_denom_pubs[err_idx],
ec,
"blinding-prepare");
break;
-
default:
GNUNET_break (0);
return TALER_MHD_reply_with_ec (rc->connection,
diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c
@@ -384,7 +384,7 @@ TEH_handler_recoup (struct MHD_Connection *connection,
union GNUNET_CRYPTO_BlindingSecretP coin_bks;
struct TALER_CoinSpendSignatureP coin_sig;
struct TALER_ExchangeWithdrawValues exchange_vals;
- struct TALER_WithdrawCommitmentHashP withdraw_commitment_h = {0};
+ struct TALER_WithdrawCommitmentHashP withdraw_commitment_h;
union GNUNET_CRYPTO_BlindSessionNonce nonce;
bool no_nonce;
struct GNUNET_JSON_Specification spec[] = {
diff --git a/src/exchange/taler-exchange-httpd_reserves_history.c b/src/exchange/taler-exchange-httpd_reserves_history.c
@@ -444,8 +444,6 @@ compile_reserve_history (
break;
}
}
-
-
return json_history;
}
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -1535,6 +1535,9 @@ withdraw_new_request (
size_t array_size = json_array_size (j_coin_evs);
const char *error = NULL;
+ _Static_assert (
+ TALER_MAX_FRESH_COINS < INT_MAX / TALER_CNC_KAPPA,
+ "TALER_MAX_FRESH_COINS too large");
#define BAIL_IF(cond, msg) \
if ((cond)) { \
@@ -1557,10 +1560,6 @@ withdraw_new_request (
(num_coins !=array_size),
"denoms_h and coin_evs must be arrays of the same size")
- _Static_assert (
- TALER_MAX_FRESH_COINS < INT_MAX / TALER_CNC_KAPPA,
- "TALER_MAX_FRESH_COINS too large");
-
BAIL_IF (wc->request.persist.age_restricted &&
((TALER_CNC_KAPPA * num_coins) != array_size),
"coin_evs must be an array of length "
diff --git a/src/exchangedb/0009-age_withdraw.sql b/src/exchangedb/0009-age_withdraw.sql
@@ -16,30 +16,28 @@
-- @author Özgür Kesim
--- Drop the table age_withdraw
CREATE FUNCTION alter_table_age_withdraw9(
IN partition_suffix TEXT DEFAULT NULL)
RETURNS VOID
LANGUAGE plpgsql
AS $$
-DECLARE
- old_name TEXT;
- new_name TEXT;
BEGIN
DROP table age_withdraw;
END;
$$;
+COMMENT ON FUNCTION alter_table_age_withdraw9
+ IS 'Drop the table age_withdraw';
INSERT INTO exchange.exchange_tables
- ( name
- , version
- , action
- , partitioned
- , by_range)
+ (name
+ ,version
+ ,action
+ ,partitioned
+ ,by_range)
VALUES
- ( 'age_withdraw9'
- , 'exchange-0009'
- , 'alter'
- , TRUE
- , FALSE);
-\ No newline at end of file
+ ('age_withdraw9'
+ ,'exchange-0009'
+ ,'alter'
+ ,TRUE
+ ,FALSE);
diff --git a/src/lib/exchange_api_blinding_prepare.c b/src/lib/exchange_api_blinding_prepare.c
@@ -158,7 +158,7 @@ blinding_prepare_ok (struct TALER_EXCHANGE_BlindingPrepareHandle *handle,
sizeof(csv->r_pub[1])),
GNUNET_JSON_spec_end ()
};
- struct GNUNET_JSON_Specification spec[] = {
+ struct GNUNET_JSON_Specification jspec[] = {
TALER_JSON_spec_tuple_of (NULL, tuple),
GNUNET_JSON_spec_end ()
};
@@ -167,7 +167,7 @@ blinding_prepare_ok (struct TALER_EXCHANGE_BlindingPrepareHandle *handle,
if (GNUNET_OK !=
GNUNET_JSON_parse (j_pair,
- spec,
+ jspec,
&err_msg,
&err_line))
{
diff --git a/src/lib/exchange_api_withdraw.c b/src/lib/exchange_api_withdraw.c
@@ -397,29 +397,32 @@ withdraw_blinded_ok (
{
struct TALER_BlindedDenominationSignature denoms_sig[wbh->num_input];
- json_t *j_sig;
- size_t i;
memset (denoms_sig,
0,
sizeof(denoms_sig));
/* Reconstruct the coins and unblind the signatures */
- json_array_foreach (j_sigs, i, j_sig)
{
- struct GNUNET_JSON_Specification ispec[] = {
- TALER_JSON_spec_blinded_denom_sig (NULL,
- &denoms_sig[i]),
- GNUNET_JSON_spec_end ()
- };
+ json_t *j_sig;
+ size_t i;
- if (GNUNET_OK !=
- GNUNET_JSON_parse (j_sig,
- ispec,
- NULL, NULL))
+ json_array_foreach (j_sigs, i, j_sig)
{
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ struct GNUNET_JSON_Specification ispec[] = {
+ TALER_JSON_spec_blinded_denom_sig (NULL,
+ &denoms_sig[i]),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (j_sig,
+ ispec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
}
}
diff --git a/src/util/crypto.c b/src/util/crypto.c
@@ -152,16 +152,19 @@ TALER_expand_withdraw_secrets (
const struct TALER_WithdrawMasterSeedP *seed,
struct TALER_PlanchetMasterSecretP secrets[static num_coins])
{
- GNUNET_assert (0<num_coins);
_Static_assert (sizeof(seed->seed_data) == sizeof(secrets->key_data));
+ GNUNET_assert (0 < num_coins);
- if (num_coins ==1)
+ if (1 == num_coins)
+ {
GNUNET_memcpy (&secrets[0].key_data,
&seed->seed_data,
sizeof(secrets[0].key_data));
+ }
else
{
uint32_t be_salt = htonl (num_coins);
+
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_kdf (secrets,
sizeof (*secrets) * num_coins,
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
@@ -713,8 +713,7 @@ TALER_wallet_blinded_planchets_hash (
struct TALER_BlindedCoinHashP bch;
struct GNUNET_HashContext *coins_hctx;
- GNUNET_assert (num_planchets >0);
- GNUNET_assert (NULL != blinded_planchets);
+ GNUNET_assert (num_planchets > 0);
GNUNET_assert (NULL != h_planchets);
coins_hctx = GNUNET_CRYPTO_hash_context_start ();