donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 756c2ba769ab71933348876e03d34375a02c1644
parent f596a36d86a59b72804de4bbda06e10097265261
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sat,  2 Aug 2025 13:27:12 +0200

fix compiler warnings, NP-deref, leaks

Diffstat:
Msrc/donau/donau-httpd_batch-submit.c | 2+-
Msrc/donau/donau-httpd_charity_insert.c | 2+-
Msrc/donau/donau-httpd_config.c | 1+
Msrc/donau/donau-httpd_config.h | 2+-
Msrc/donau/donau-httpd_keys.c | 20++++++++++++++------
Msrc/include/donau_service.h | 9+++++++--
Msrc/lib/donau_api_charities_get.c | 27++++++++++++++++++---------
Msrc/lib/donau_api_handle.c | 10+++++-----
Msrc/testing/testing_api_cmd_charities_get.c | 2+-
Msrc/testing/testing_api_cmd_charity_delete.c | 2+-
Msrc/testing/testing_api_cmd_charity_get.c | 1+
Msrc/testing/testing_api_cmd_charity_post.c | 2+-
Msrc/testing/testing_api_cmd_donation_statement_get.c | 4+++-
Msrc/testing/testing_api_cmd_get_donau.c | 1+
Msrc/testing/testing_api_cmd_issue_receipts.c | 3++-
Msrc/testing/testing_api_cmd_submit_receipts.c | 3++-
16 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c @@ -85,7 +85,6 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc, { struct InsertReceiptContext irc = {0}; const json_t *donation_receipts; - struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("h_donor_tax_id", &irc.h_donor_tax_id), @@ -96,6 +95,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc, GNUNET_JSON_spec_end () }; + (void) args; { enum GNUNET_GenericReturnValue res; diff --git a/src/donau/donau-httpd_charity_insert.c b/src/donau/donau-httpd_charity_insert.c @@ -102,7 +102,6 @@ DH_handler_charity_post (struct DH_RequestContext *rc, const char *const args[]) { struct InsertCharityContext icc; - struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("charity_pub", &icc.charity_pub), @@ -121,6 +120,7 @@ DH_handler_charity_post (struct DH_RequestContext *rc, GNUNET_JSON_spec_end () }; + (void) args; { enum GNUNET_GenericReturnValue res; diff --git a/src/donau/donau-httpd_config.c b/src/donau/donau-httpd_config.c @@ -33,6 +33,7 @@ DH_handler_config (struct DH_RequestContext *rc, { static struct MHD_Response *resp; + (void) args; if (NULL == resp) { resp = TALER_MHD_MAKE_JSON_PACK ( diff --git a/src/donau/donau-httpd_config.h b/src/donau/donau-httpd_config.h @@ -41,7 +41,7 @@ * * Returned via both /config and /keys endpoints. */ -#define DONAU_PROTOCOL_VERSION "0:0:0" +#define DONAU_PROTOCOL_VERSION "0:1:0" /** diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c @@ -379,6 +379,7 @@ insert_donation_unit_cb (void *cls, struct KeysBuilderContext *kbc = cls; struct DH_DonationUnitKey *du = value; + (void) h_du_pub; GNUNET_assert ( 0 == json_array_append_new ( kbc->donation_units, @@ -660,8 +661,7 @@ destroy_key_state (struct DH_KeyStateHandle *ksh) * @param h_rsa hash of the @a donation_unit_pub that is available (or was purged) * @param bs_pub the public key itself, NULL if the key was revoked or purged * @param sm_pub public key of the security module, NULL if the key was revoked or purged - * @param sm_sig signature from the security module, NULL if the key was revoked or purged - * The signature was already verified against @a sm_pub. + * @param sm_sig signature from the security module */ static void helper_rsa_cb ( @@ -678,6 +678,8 @@ helper_rsa_cb ( struct TALER_Amount value; enum GNUNET_DB_QueryStatus qs; + (void) cls; + (void) sm_sig; /* not using offline signatures */ GNUNET_assert (GNUNET_CRYPTO_BSA_RSA == bs_pub->cipher); if (GNUNET_OK != TALER_config_get_amount (DH_cfg, @@ -760,7 +762,8 @@ helper_rsa_cb ( * @param validity_duration how long does the key remain available for signing; * zero if the key has been revoked or purged * @param h_cs hash of the @a donation_unit_pub that is available (or was purged) - * @param bs_pub the public key itself, NULL if the key was revoked or purged + * @param sm_pub the public key itself, NULL if the key was revoked or purged + * @param sm_pub signature by the security module */ static void helper_cs_cb ( @@ -777,6 +780,8 @@ helper_cs_cb ( struct TALER_Amount value; enum GNUNET_DB_QueryStatus qs; + (void) cls; + (void) sm_sig; /* we are not using offline signatures */ GNUNET_assert (GNUNET_CRYPTO_BSA_CS == bs_pub->cipher); if (GNUNET_OK != TALER_config_get_amount (DH_cfg, @@ -858,8 +863,7 @@ helper_cs_cb ( * zero if the key has been revoked or purged * @param donau_pub the public key itself, NULL if the key was revoked or purged * @param sm_pub public key of the security module, NULL if the key was revoked or purged - * @param sm_sig signature from the security module, NULL if the key was revoked or purged - * The signature was already verified against @a sm_pub. + * @param sm_sig signature from the security module */ static void helper_esign_cb ( @@ -873,13 +877,14 @@ helper_esign_cb ( struct SigningKey *sk; struct GNUNET_PeerIdentity pid; unsigned long long expire_legal; - /* need to "cast" because secmod works with TALER_ExchangePublicKeyP */ struct DONAU_DonauPublicKeyP donau_pubkey = { .eddsa_pub = donau_pub->eddsa_pub }; enum GNUNET_DB_QueryStatus qs; + (void) cls; + (void) sm_sig; /* not using offline signing */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "EdDSA helper announces signing key %s with validity %s\n", TALER_B2S (donau_pub), @@ -1017,6 +1022,7 @@ donation_unit_info_cb ( { struct DH_DonationUnitKey *du; + (void) cls; GNUNET_assert (GNUNET_CRYPTO_BSA_INVALID != donation_unit_pub->bsign_pub_key->cipher); du = GNUNET_CONTAINER_multihashmap_get (du_keys, @@ -1067,6 +1073,7 @@ iterate_active_signing_keys_cb ( }; struct SigningKey *sk; + (void) cls; sk = GNUNET_CONTAINER_multipeermap_get (esign_keys, &pid); if (NULL != sk) @@ -1192,6 +1199,7 @@ DH_handler_keys (struct DH_RequestContext *rc, struct DH_KeyStateHandle *ksh; struct MHD_Response *resp; + (void) args; sync_key_helpers (); ksh = DH_keys_get_state (); if (NULL == ksh) diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -893,7 +893,7 @@ struct DONAU_CharitySummary /** * charity name */ - char *name; + const char *name; /** * Max donation amout for this charitiy and year. @@ -941,7 +941,12 @@ struct DONAU_GetCharitiesResponse /** * Charity status information. */ - struct DONAU_CharitySummary *charity; + struct DONAU_CharitySummary *charities; + + /** + * Length of the @e charities array. + */ + size_t num_charities; } ok; diff --git a/src/lib/donau_api_charities_get.c b/src/lib/donau_api_charities_get.c @@ -71,25 +71,31 @@ handle_charities_get_ok (const json_t *resp_obj, struct DONAU_CharitiesGetHandle *cgh, struct DONAU_GetCharitiesResponse *gcresp) { - struct DONAU_CharitySummary *charities = gcresp->details.ok.charity; - const char *name; - if (JSON_OBJECT != json_typeof (resp_obj)) + struct DONAU_CharitySummary *charities = NULL; + const json_t *ca = json_object_get (resp_obj, + "charities"); + size_t num_charity + = json_array_size (ca); + + if (JSON_ARRAY != json_typeof (ca)) { GNUNET_break_op (0); return GNUNET_SYSERR; } - const unsigned long long num_charity - = json_array_size (resp_obj); if (0 != num_charity) { - unsigned int index; + size_t index; json_t *charity_obj; - json_array_foreach (resp_obj, + + charities = GNUNET_new_array (num_charity, + struct DONAU_CharitySummary); + json_array_foreach (ca, index, charity_obj) { struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("name", &name), + GNUNET_JSON_spec_string ("name", + &charities[index].name), TALER_JSON_spec_amount_any ("max_per_year", &charities[index].max_per_year), TALER_JSON_spec_amount_any ("receipts_to_date", @@ -99,6 +105,7 @@ handle_charities_get_ok (const json_t *resp_obj, &charities[index].charity_id), GNUNET_JSON_spec_end () }; + if (GNUNET_OK != GNUNET_JSON_parse (resp_obj, spec, @@ -108,12 +115,14 @@ handle_charities_get_ok (const json_t *resp_obj, GNUNET_break_op (0); return GNUNET_SYSERR; } - charities[index].name = GNUNET_strdup (name); } + gcresp->details.ok.num_charities = num_charity; + gcresp->details.ok.charities = charities; } cgh->cb (cgh->cb_cls, gcresp); cgh->cb = NULL; + GNUNET_free (charities); return GNUNET_OK; } diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c @@ -70,7 +70,7 @@ * how long do we assume the reply to be valid at least? */ #define MINIMUM_EXPIRATION GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MINUTES, 2) + GNUNET_TIME_UNIT_MINUTES, 2) /** @@ -120,9 +120,9 @@ struct DONAU_GetKeysHandle #define EXITIF(cond) \ - do { \ - if (cond) { GNUNET_break (0); goto EXITIF_exit; } \ - } while (0) + do { \ + if (cond) { GNUNET_break (0); goto EXITIF_exit; } \ + } while (0) /** * Parse a donau's signing key encoded in JSON. @@ -634,7 +634,7 @@ DONAU_get_donation_amount_from_bkps ( } -const bool +bool DONAU_check_bkps_duplication ( const struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps, const size_t num_bkps) diff --git a/src/testing/testing_api_cmd_charities_get.c b/src/testing/testing_api_cmd_charities_get.c @@ -101,8 +101,8 @@ status_run (void *cls, { struct StatusState *ss = cls; + (void) cmd; ss->is = is; - ss->cgh = DONAU_charities_get ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), diff --git a/src/testing/testing_api_cmd_charity_delete.c b/src/testing/testing_api_cmd_charity_delete.c @@ -112,8 +112,8 @@ status_run (void *cls, { struct StatusState *ss = cls; + (void) cmd; ss->is = is; - /* Get charity id from trait */ { const struct TALER_TESTING_Command *charity_post_cmd; diff --git a/src/testing/testing_api_cmd_charity_get.c b/src/testing/testing_api_cmd_charity_get.c @@ -111,6 +111,7 @@ status_run (void *cls, { struct StatusState *ss = cls; + (void) cmd; ss->is = is; /* Get charity id from trait */ { diff --git a/src/testing/testing_api_cmd_charity_post.c b/src/testing/testing_api_cmd_charity_post.c @@ -118,8 +118,8 @@ charity_status_run (void *cls, { struct StatusState *ss = cls; + (void) cmd; ss->is = is; - ss->cph = DONAU_charity_post ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), diff --git a/src/testing/testing_api_cmd_donation_statement_get.c b/src/testing/testing_api_cmd_donation_statement_get.c @@ -98,7 +98,8 @@ donation_statement_status_cb (void *cls, "get-donau"); if (GNUNET_OK != - TALER_TESTING_get_trait_donau_keys (keys_cmd, &keys)) + TALER_TESTING_get_trait_donau_keys (keys_cmd, + &keys)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (ss->is); @@ -153,6 +154,7 @@ status_run (void *cls, { struct StatusState *ss = cls; + (void) cmd; ss->is = is; /* Get charity salted tax id hash from trait */ { diff --git a/src/testing/testing_api_cmd_get_donau.c b/src/testing/testing_api_cmd_get_donau.c @@ -159,6 +159,7 @@ get_donau_cleanup (void *cls, { struct GetDonauState *ges = cls; + (void) cmd; if (NULL != ges->donau) { DONAU_get_keys_cancel (ges->donau); diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c @@ -312,7 +312,6 @@ cs_stage_two_callback ( csr_data->ss->cs_pending--; if (0 == csr_data->ss->cs_pending) phase_two (csr_data->ss); - // GNUNET_free (csr_data); } @@ -329,6 +328,8 @@ status_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct StatusState *ss = cls; + + (void) cmd; ss->is = is; /* Get charity id and the charity private key from trait */ diff --git a/src/testing/testing_api_cmd_submit_receipts.c b/src/testing/testing_api_cmd_submit_receipts.c @@ -127,8 +127,9 @@ status_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct StatusState *ss = cls; - ss->is = is; + (void) cmd; + ss->is = is; /* Get donau keys from trait */ { const struct TALER_TESTING_Command *keys_cmd;