diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-04 13:26:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-04 13:26:00 +0200 |
commit | 809300158caaa0215c36ef89c7e38f0edfa93593 (patch) | |
tree | 1faf7e314af34db7a2333d8003ee0ed6fca91d74 /src/exchange | |
parent | 9718bc4920ab4781378b777bf3e2af275c8d0575 (diff) |
code cleanup, fixing misc. memory leaks in the process
Diffstat (limited to 'src/exchange')
13 files changed, 89 insertions, 155 deletions
diff --git a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c index 776c0d8d..d604632d 100644 --- a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c +++ b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c @@ -984,14 +984,18 @@ TEH_handler_age_withdraw_reveal ( MHD_RESULT result = MHD_NO; enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR; struct AgeRevealContext actx = {0}; - json_t *j_denoms_h; - json_t *j_coin_evs; - json_t *j_disclosed_coin_secrets; + const json_t *j_denoms_h; + const json_t *j_coin_evs; + const json_t *j_disclosed_coin_secrets; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("reserve_pub", &actx.reserve_pub), - GNUNET_JSON_spec_json ("denoms_h", &j_denoms_h), - GNUNET_JSON_spec_json ("coin_evs", &j_coin_evs), - GNUNET_JSON_spec_json ("disclosed_coin_secrets", &j_disclosed_coin_secrets), + GNUNET_JSON_spec_fixed_auto ("reserve_pub", + &actx.reserve_pub), + GNUNET_JSON_spec_array_const ("denoms_h", + &j_denoms_h), + GNUNET_JSON_spec_array_const ("coin_evs", + &j_coin_evs), + GNUNET_JSON_spec_array_const ("disclosed_coin_secrets", + &j_disclosed_coin_secrets), GNUNET_JSON_spec_end () }; @@ -1010,7 +1014,8 @@ TEH_handler_age_withdraw_reveal ( do { /* Extract denominations, blinded and disclosed coins */ - if (GNUNET_OK != parse_age_withdraw_reveal_json ( + if (GNUNET_OK != + parse_age_withdraw_reveal_json ( rc->connection, j_denoms_h, j_coin_evs, @@ -1020,7 +1025,8 @@ TEH_handler_age_withdraw_reveal ( break; /* Find original commitment */ - if (GNUNET_OK != find_original_commitment ( + if (GNUNET_OK != + find_original_commitment ( rc->connection, &actx.ach, &actx.reserve_pub, @@ -1029,7 +1035,8 @@ TEH_handler_age_withdraw_reveal ( break; /* Ensure validity of denoms and the sum of amounts and fees */ - if (GNUNET_OK != are_denominations_valid ( + if (GNUNET_OK != + are_denominations_valid ( rc->connection, actx.num_coins, actx.denoms_h, @@ -1043,7 +1050,8 @@ TEH_handler_age_withdraw_reveal ( /* Verify the computed h_commitment equals the committed one and that coins * have a maximum age group corresponding max_age (age-mask dependent) */ - if (GNUNET_OK != verify_commitment_and_max_age ( + if (GNUNET_OK != + verify_commitment_and_max_age ( rc->connection, &actx.commitment.h_commitment, actx.commitment.max_age, @@ -1056,7 +1064,8 @@ TEH_handler_age_withdraw_reveal ( break; /* Finally, sign and persist the coins */ - if (GNUNET_OK != sign_and_finalize_age_withdraw ( + if (GNUNET_OK != + sign_and_finalize_age_withdraw ( rc->connection, &actx.commitment.h_commitment, actx.num_coins, @@ -1068,7 +1077,6 @@ TEH_handler_age_withdraw_reveal ( } while(0); age_reveal_context_free (&actx); - GNUNET_JSON_parse_free (spec); return result; } diff --git a/src/exchange/taler-exchange-httpd_aml-decision.c b/src/exchange/taler-exchange-httpd_aml-decision.c index 2830e54e..c1439adc 100644 --- a/src/exchange/taler-exchange-httpd_aml-decision.c +++ b/src/exchange/taler-exchange-httpd_aml-decision.c @@ -74,7 +74,7 @@ struct DecisionContext /** * KYC requirements imposed, NULL for none. */ - json_t *kyc_requirements; + const json_t *kyc_requirements; }; @@ -261,8 +261,8 @@ TEH_handler_post_aml_decision ( GNUNET_JSON_spec_uint32 ("new_state", &new_state32), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_json ("kyc_requirements", - &dc.kyc_requirements), + GNUNET_JSON_spec_array_const ("kyc_requirements", + &dc.kyc_requirements), NULL), GNUNET_JSON_spec_end () }; @@ -306,17 +306,6 @@ TEH_handler_post_aml_decision ( size_t index; json_t *elem; - if (! json_is_array (dc.kyc_requirements)) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "kyc_requirements must be an array"); - } - json_array_foreach (dc.kyc_requirements, index, elem) { const char *val; @@ -324,7 +313,6 @@ TEH_handler_post_aml_decision ( if (! json_is_string (elem)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, @@ -336,7 +324,6 @@ TEH_handler_post_aml_decision ( TALER_KYCLOGIC_check_satisfiable (val)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, @@ -357,11 +344,9 @@ TEH_handler_post_aml_decision ( &make_aml_decision, &dc)) { - GNUNET_JSON_parse_free (spec); return mhd_ret; } } - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_static ( connection, MHD_HTTP_NO_CONTENT, diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c index d000c454..488f85ab 100644 --- a/src/exchange/taler-exchange-httpd_batch-deposit.c +++ b/src/exchange/taler-exchange-httpd_batch-deposit.c @@ -545,7 +545,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, { struct MHD_Connection *connection = rc->connection; struct BatchDepositContext dc; - json_t *coins; + const json_t *coins; bool no_refund_deadline = true; bool no_policy_json = true; struct GNUNET_JSON_Specification spec[] = { @@ -557,8 +557,8 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, &dc.merchant_pub), GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &dc.h_contract_terms), - GNUNET_JSON_spec_json ("coins", - &coins), + GNUNET_JSON_spec_array_const ("coins", + &coins), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("policy", &dc.policy_json), diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c index c3065e1d..9d7d64cb 100644 --- a/src/exchange/taler-exchange-httpd_batch-withdraw.c +++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c @@ -843,10 +843,10 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc, .reserve_pub = reserve_pub, .rc = rc }; - json_t *planchets; + const json_t *planchets; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("planchets", - &planchets), + GNUNET_JSON_spec_array_const ("planchets", + &planchets), GNUNET_JSON_spec_end () }; @@ -862,20 +862,17 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc, if (GNUNET_OK != res) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } - if ( (! json_is_array (planchets)) || - (0 == json_array_size (planchets)) ) + wc.planchets_length = json_array_size (planchets); + if (0 == wc.planchets_length) { - GNUNET_JSON_parse_free (spec); GNUNET_break_op (0); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, "planchets"); } - wc.planchets_length = json_array_size (planchets); if (wc.planchets_length > TALER_MAX_FRESH_COINS) { - GNUNET_JSON_parse_free (spec); GNUNET_break_op (0); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_BAD_REQUEST, @@ -901,7 +898,6 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc, TALER_blinded_planchet_free (&pc->blinded_planchet); TALER_blinded_denom_sig_free (&pc->collectable.sig); } - GNUNET_JSON_parse_free (spec); return ret; } } diff --git a/src/exchange/taler-exchange-httpd_csr.c b/src/exchange/taler-exchange-httpd_csr.c index 29f83c2c..3ceb319c 100644 --- a/src/exchange/taler-exchange-httpd_csr.c +++ b/src/exchange/taler-exchange-httpd_csr.c @@ -39,12 +39,12 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc, { struct TALER_RefreshMasterSecretP rms; unsigned int csr_requests_num; - json_t *csr_requests; + const json_t *csr_requests; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("rms", &rms), - GNUNET_JSON_spec_json ("nks", - &csr_requests), + GNUNET_JSON_spec_array_const ("nks", + &csr_requests), GNUNET_JSON_spec_end () }; enum TALER_ErrorCode ec; @@ -65,7 +65,7 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc, if ( (TALER_MAX_FRESH_COINS <= csr_requests_num) || (0 == csr_requests_num) ) { - GNUNET_JSON_parse_free (spec); + GNUNET_break_op (0); return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_BAD_REQUEST, @@ -101,14 +101,12 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc, -1); if (GNUNET_OK != res) { - GNUNET_JSON_parse_free (spec); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } TALER_cs_refresh_nonce_derive (&rms, coin_off, &nonces[i]); } - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i < csr_requests_num; i++) { diff --git a/src/exchange/taler-exchange-httpd_management_extensions.c b/src/exchange/taler-exchange-httpd_management_extensions.c index d5841a3c..3b24bace 100644 --- a/src/exchange/taler-exchange-httpd_management_extensions.c +++ b/src/exchange/taler-exchange-httpd_management_extensions.c @@ -145,7 +145,7 @@ set_extensions (void *cls, static enum GNUNET_GenericReturnValue verify_extensions_from_json ( - json_t *extensions, + const json_t *extensions, struct SetExtensionsContext *sec) { const char*name; @@ -160,7 +160,7 @@ verify_extensions_from_json ( sec->extensions = GNUNET_new_array (sec->num_extensions, struct Extension); - json_object_foreach (extensions, name, manifest) + json_object_foreach ((json_t *) extensions, name, manifest) { int critical = 0; json_t *config; @@ -200,11 +200,11 @@ TEH_handler_management_post_extensions ( const json_t *root) { MHD_RESULT ret; - json_t *extensions; + const json_t *extensions; struct SetExtensionsContext sec = {0}; struct GNUNET_JSON_Specification top_spec[] = { - GNUNET_JSON_spec_json ("extensions", - &extensions), + GNUNET_JSON_spec_object_const ("extensions", + &extensions), GNUNET_JSON_spec_fixed_auto ("extensions_sig", &sec.extensions_sig), GNUNET_JSON_spec_end () @@ -223,31 +223,19 @@ TEH_handler_management_post_extensions ( return MHD_YES; /* failure */ } - /* Ensure we have an object */ - if ((! json_is_object (extensions)) && - (! json_is_null (extensions))) - { - GNUNET_JSON_parse_free (top_spec); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "invalid object"); - } - /* Verify the signature */ { struct TALER_ExtensionManifestsHashP h_manifests; if (GNUNET_OK != - TALER_JSON_extensions_manifests_hash (extensions, &h_manifests) || + TALER_JSON_extensions_manifests_hash (extensions, + &h_manifests) || GNUNET_OK != TALER_exchange_offline_extension_manifests_hash_verify ( &h_manifests, &TEH_master_public_key, &sec.extensions_sig)) { - GNUNET_JSON_parse_free (top_spec); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, @@ -263,7 +251,6 @@ TEH_handler_management_post_extensions ( if (GNUNET_OK != verify_extensions_from_json (extensions, &sec)) { - GNUNET_JSON_parse_free (top_spec); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, @@ -306,7 +293,6 @@ CLEANUP: } } GNUNET_free (sec.extensions); - GNUNET_JSON_parse_free (top_spec); return ret; } diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c index df351ad5..0ddc4691 100644 --- a/src/exchange/taler-exchange-httpd_management_post_keys.c +++ b/src/exchange/taler-exchange-httpd_management_post_keys.c @@ -340,13 +340,13 @@ TEH_handler_management_post_keys ( const json_t *root) { struct AddKeysContext akc; - json_t *denom_sigs; - json_t *signkey_sigs; + const json_t *denom_sigs; + const json_t *signkey_sigs; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("denom_sigs", - &denom_sigs), - GNUNET_JSON_spec_json ("signkey_sigs", - &signkey_sigs), + GNUNET_JSON_spec_array_const ("denom_sigs", + &denom_sigs), + GNUNET_JSON_spec_array_const ("signkey_sigs", + &signkey_sigs), GNUNET_JSON_spec_end () }; bool ok; @@ -363,24 +363,12 @@ TEH_handler_management_post_keys ( if (GNUNET_NO == res) return MHD_YES; /* failure */ } - if (! (json_is_array (denom_sigs) && - json_is_array (signkey_sigs)) ) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "array expected for denom_sigs and signkey_sigs"); - } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received /management/keys\n"); akc.ksh = TEH_keys_get_state_for_management_only (); /* may start its own transaction, thus must be done here, before we run ours! */ if (NULL == akc.ksh) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, @@ -423,7 +411,6 @@ TEH_handler_management_post_keys ( if (! ok) { GNUNET_free (akc.d_sigs); - GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failure to handle /management/keys\n"); return ret; @@ -466,7 +453,6 @@ TEH_handler_management_post_keys ( "Failure to handle /management/keys\n"); GNUNET_free (akc.d_sigs); GNUNET_free (akc.s_sigs); - GNUNET_JSON_parse_free (spec); return ret; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -484,7 +470,6 @@ TEH_handler_management_post_keys ( &akc); GNUNET_free (akc.d_sigs); GNUNET_free (akc.s_sigs); - GNUNET_JSON_parse_free (spec); if (GNUNET_SYSERR == res) return ret; } diff --git a/src/exchange/taler-exchange-httpd_management_wire_enable.c b/src/exchange/taler-exchange-httpd_management_wire_enable.c index 6743b485..a67d1ad6 100644 --- a/src/exchange/taler-exchange-httpd_management_wire_enable.c +++ b/src/exchange/taler-exchange-httpd_management_wire_enable.c @@ -62,12 +62,12 @@ struct AddWireContext /** * Restrictions imposed when crediting this account. */ - json_t *credit_restrictions; + const json_t *credit_restrictions; /** * Restrictions imposed when debiting this account. */ - json_t *debit_restrictions; + const json_t *debit_restrictions; /** * Timestamp for checking against replay attacks. @@ -176,10 +176,10 @@ TEH_handler_management_post_wire ( GNUNET_JSON_spec_string ("conversion_url", &awc.conversion_url), NULL), - GNUNET_JSON_spec_json ("credit_restrictions", - &awc.credit_restrictions), - GNUNET_JSON_spec_json ("debit_restrictions", - &awc.debit_restrictions), + GNUNET_JSON_spec_array_const ("credit_restrictions", + &awc.credit_restrictions), + GNUNET_JSON_spec_array_const ("debit_restrictions", + &awc.debit_restrictions), GNUNET_JSON_spec_timestamp ("validity_start", &awc.validity_start), GNUNET_JSON_spec_end () diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c index 130f9fae..2de9468f 100644 --- a/src/exchange/taler-exchange-httpd_purses_create.c +++ b/src/exchange/taler-exchange-httpd_purses_create.c @@ -430,7 +430,7 @@ TEH_handler_purses_create ( .pd.purse_pub = *purse_pub, .exchange_timestamp = GNUNET_TIME_timestamp_get () }; - json_t *deposits; + const json_t *deposits; json_t *deposit; unsigned int idx; struct GNUNET_JSON_Specification spec[] = { @@ -449,8 +449,8 @@ TEH_handler_purses_create ( &pcc.purse_sig), GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &pcc.pd.h_contract_terms), - GNUNET_JSON_spec_json ("deposits", - &deposits), + GNUNET_JSON_spec_array_const ("deposits", + &deposits), GNUNET_JSON_spec_timestamp ("purse_expiration", &pcc.pd.purse_expiration), GNUNET_JSON_spec_end () @@ -482,7 +482,6 @@ TEH_handler_purses_create ( pcc.exchange_timestamp)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_BEFORE_NOW, @@ -491,7 +490,6 @@ TEH_handler_purses_create ( if (GNUNET_TIME_absolute_is_never (pcc.pd.purse_expiration.abs_time)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_IS_NEVER, @@ -502,7 +500,6 @@ TEH_handler_purses_create ( (pcc.num_coins > TALER_MAX_FRESH_COINS) ) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -515,7 +512,6 @@ TEH_handler_purses_create ( if (NULL == keys) { GNUNET_break (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, @@ -547,7 +543,6 @@ TEH_handler_purses_create ( deposit); if (GNUNET_OK != res) { - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<idx; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -559,7 +554,6 @@ TEH_handler_purses_create ( &pcc.deposit_total)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); GNUNET_free (pcc.coins); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, @@ -579,7 +573,6 @@ TEH_handler_purses_create ( &pcc.purse_sig)) { TALER_LOG_WARNING ("Invalid signature on /purses/$PID/create request\n"); - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -597,7 +590,6 @@ TEH_handler_purses_create ( &pcc.econtract.econtract_sig)) ) { TALER_LOG_WARNING ("Invalid signature on /purses/$PID/create request\n"); - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -612,7 +604,6 @@ TEH_handler_purses_create ( TEH_plugin->preflight (TEH_plugin->cls)) { GNUNET_break (0); - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -634,7 +625,6 @@ TEH_handler_purses_create ( &create_transaction, &pcc)) { - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -653,7 +643,6 @@ TEH_handler_purses_create ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); - GNUNET_JSON_parse_free (spec); return res; } } diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c index 291807aa..973dfccf 100644 --- a/src/exchange/taler-exchange-httpd_purses_deposit.c +++ b/src/exchange/taler-exchange-httpd_purses_deposit.c @@ -329,12 +329,12 @@ TEH_handler_purses_deposit ( .purse_pub = purse_pub, .exchange_timestamp = GNUNET_TIME_timestamp_get () }; - json_t *deposits; + const json_t *deposits; json_t *deposit; unsigned int idx; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("deposits", - &deposits), + GNUNET_JSON_spec_array_const ("deposits", + &deposits), GNUNET_JSON_spec_end () }; @@ -363,7 +363,6 @@ TEH_handler_purses_deposit ( (pcc.num_coins > TALER_MAX_FRESH_COINS) ) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -435,7 +434,6 @@ TEH_handler_purses_deposit ( deposit); if (GNUNET_OK != res) { - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<idx; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -447,7 +445,6 @@ TEH_handler_purses_deposit ( TEH_plugin->preflight (TEH_plugin->cls)) { GNUNET_break (0); - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -469,7 +466,6 @@ TEH_handler_purses_deposit ( &deposit_transaction, &pcc)) { - GNUNET_JSON_parse_free (spec); for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); @@ -501,7 +497,6 @@ TEH_handler_purses_deposit ( for (unsigned int i = 0; i<pcc.num_coins; i++) TEH_common_purse_deposit_free_coin (&pcc.coins[i]); GNUNET_free (pcc.coins); - GNUNET_JSON_parse_free (spec); return res; } } diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index 89bdf272..47926a74 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -983,26 +983,26 @@ TEH_handler_reveal (struct TEH_RequestContext *rc, const json_t *root, const char *const args[2]) { - json_t *coin_evs; - json_t *transfer_privs; - json_t *link_sigs; - json_t *new_denoms_h; - json_t *old_age_commitment; + const json_t *coin_evs; + const json_t *transfer_privs; + const json_t *link_sigs; + const json_t *new_denoms_h; + const json_t *old_age_commitment; struct RevealContext rctx; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("transfer_pub", &rctx.gamma_tp), - GNUNET_JSON_spec_json ("transfer_privs", - &transfer_privs), - GNUNET_JSON_spec_json ("link_sigs", - &link_sigs), - GNUNET_JSON_spec_json ("coin_evs", - &coin_evs), - GNUNET_JSON_spec_json ("new_denoms_h", - &new_denoms_h), + GNUNET_JSON_spec_array_const ("transfer_privs", + &transfer_privs), + GNUNET_JSON_spec_array_const ("link_sigs", + &link_sigs), + GNUNET_JSON_spec_array_const ("coin_evs", + &coin_evs), + GNUNET_JSON_spec_array_const ("new_denoms_h", + &new_denoms_h), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_json ("old_age_commitment", - &old_age_commitment), + GNUNET_JSON_spec_array_const ("old_age_commitment", + &old_age_commitment), NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_fixed_auto ("rms", @@ -1053,7 +1053,6 @@ TEH_handler_reveal (struct TEH_RequestContext *rc, /* Note we do +1 as 1 row (cut-and-choose!) is missing! */ if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1) { - GNUNET_JSON_parse_free (spec); GNUNET_break_op (0); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_BAD_REQUEST, @@ -1061,19 +1060,13 @@ TEH_handler_reveal (struct TEH_RequestContext *rc, NULL); } - { - MHD_RESULT res; - - res = handle_refreshes_reveal_json (rc->connection, - &rctx, - transfer_privs, - link_sigs, - new_denoms_h, - old_age_commitment, - coin_evs); - GNUNET_JSON_parse_free (spec); - return res; - } + return handle_refreshes_reveal_json (rc->connection, + &rctx, + transfer_privs, + link_sigs, + new_denoms_h, + old_age_commitment, + coin_evs); } diff --git a/src/exchange/taler-exchange-httpd_reserves_attest.c b/src/exchange/taler-exchange-httpd_reserves_attest.c index d0f3614e..7bbebaad 100644 --- a/src/exchange/taler-exchange-httpd_reserves_attest.c +++ b/src/exchange/taler-exchange-httpd_reserves_attest.c @@ -68,7 +68,7 @@ struct ReserveAttestContext /** * List of requested details. */ - json_t *details; + const json_t *details; /** * Client signature approving the request. @@ -287,8 +287,8 @@ TEH_handler_reserves_attest (struct TEH_RequestContext *rc, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_timestamp ("request_timestamp", &rsc.timestamp), - GNUNET_JSON_spec_json ("details", - &rsc.details), + GNUNET_JSON_spec_array_const ("details", + &rsc.details), GNUNET_JSON_spec_fixed_auto ("reserve_sig", &rsc.reserve_sig), GNUNET_JSON_spec_end () diff --git a/src/exchange/taler-exchange-httpd_reserves_open.c b/src/exchange/taler-exchange-httpd_reserves_open.c index 6909c862..50487990 100644 --- a/src/exchange/taler-exchange-httpd_reserves_open.c +++ b/src/exchange/taler-exchange-httpd_reserves_open.c @@ -303,7 +303,7 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc, const json_t *root) { struct ReserveOpenContext rsc; - json_t *payments; + const json_t *payments; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_timestamp ("request_timestamp", &rsc.timestamp), @@ -313,8 +313,8 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc, &rsc.reserve_sig), GNUNET_JSON_spec_uint32 ("purse_limit", &rsc.purse_limit), - GNUNET_JSON_spec_json ("payments", - &payments), + GNUNET_JSON_spec_array_const ("payments", + &payments), TALER_JSON_spec_amount ("reserve_payment", TEH_currency, &rsc.reserve_payment), @@ -403,7 +403,6 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc, if (NULL == keys) { GNUNET_break (0); - GNUNET_JSON_parse_free (spec); cleanup_rsc (&rsc); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, |