diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-19 20:56:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-19 20:56:53 +0100 |
commit | 52fe9d657bd54e622e8b87070c29ac0ffc27c575 (patch) | |
tree | 37d6b3cd84bff3e45b13b22b09d9ca938073c9fd /src/lib | |
parent | 7b5eb6137061128f987260ba681231e28ae260d5 (diff) | |
download | exchange-52fe9d657bd54e622e8b87070c29ac0ffc27c575.tar.xz |
-fix leaks and compiler warnings
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/exchange_api_common.c | 2 | ||||
-rw-r--r-- | src/lib/exchange_api_refresh_common.c | 9 | ||||
-rw-r--r-- | src/lib/exchange_api_refund.c | 38 |
3 files changed, 37 insertions, 12 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 900c871d2..38c4ce1a3 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -679,7 +679,7 @@ TALER_EXCHANGE_verify_coin_history ( for the exchange to lie here, so not checking is probably OK (an auditor ought to check, though). Then again, we similarly had no reason to check the merchant's signature (other than a - well-formendess check). */// + well-formendess check). */ /* check that refund fee matches our expectations from /keys! */ if (NULL != dk) diff --git a/src/lib/exchange_api_refresh_common.c b/src/lib/exchange_api_refresh_common.c index 520c80fd4..4f2a2cf18 100644 --- a/src/lib/exchange_api_refresh_common.c +++ b/src/lib/exchange_api_refresh_common.c @@ -198,11 +198,11 @@ serialize_melt_data (const struct MeltData *md) GNUNET_JSON_pack_data_auto ("ps", &md->fresh_coins[j][i])); GNUNET_assert (0 == - json_array_append (planchet_secrets, - ps)); + json_array_append_new (planchet_secrets, + ps)); } GNUNET_assert (0 == - json_array_append ( + json_array_append_new ( fresh_coins, GNUNET_JSON_PACK ( TALER_JSON_pack_denom_pub ("denom_pub", @@ -299,6 +299,7 @@ TALER_EXCHANGE_deserialize_melt_data_ (const json_t *melt_data, { GNUNET_break (0); ok = false; + GNUNET_JSON_parse_free (ispec); break; } for (unsigned int j = 0; j<TALER_CNC_KAPPA; j++) @@ -320,10 +321,12 @@ TALER_EXCHANGE_deserialize_melt_data_ (const json_t *melt_data, break; } } + json_decref (planchet_secrets); if (! ok) break; } + GNUNET_JSON_parse_free (spec); if (! ok) { TALER_EXCHANGE_free_melt_data_ (md); diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 1362a9c26..6e9d416df 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -166,6 +166,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, if (0 == len) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } have_deposit = false; @@ -191,6 +192,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, NULL, NULL)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if (0 == strcasecmp (type, @@ -205,7 +207,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_TIME_Absolute refund_deadline; struct TALER_CoinSpendSignatureP sig; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("coin_sig", &sig), GNUNET_JSON_spec_fixed_auto ("h_contract_terms", @@ -227,10 +229,11 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, if (GNUNET_OK != GNUNET_JSON_parse (transaction, - spec, + ispec, NULL, NULL)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if (GNUNET_OK != @@ -247,6 +250,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &sig)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if ( (0 != GNUNET_memcmp (&rh->depconf.h_contract_terms, @@ -256,6 +260,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, { /* deposit information is about a different merchant/contract */ GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if (have_deposit) @@ -266,6 +271,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &dtotal)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } GNUNET_break (0 <= @@ -290,7 +296,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND), .coin_pub = rh->depconf.coin_pub }; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { TALER_JSON_spec_amount_any ("refund_fee", &refund_fee), GNUNET_JSON_spec_fixed_auto ("merchant_sig", @@ -306,10 +312,11 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, if (GNUNET_OK != GNUNET_JSON_parse (transaction, - spec, + ispec, NULL, NULL)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if (0 > @@ -318,6 +325,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &amount)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } TALER_amount_hton (&rr.refund_amount, @@ -330,6 +338,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &rr.merchant.eddsa_pub)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if ( (0 != GNUNET_memcmp (&rh->depconf.h_contract_terms, @@ -339,6 +348,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, { /* refund is about a different merchant/contract */ GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if (rr.rtransaction_id == rh->depconf.rtransaction_id) @@ -346,6 +356,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, /* Eh, this shows either a dependency failure or idempotency, but must not happen in a conflict reply. Fail! */ GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } @@ -356,6 +367,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &rtotal)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } GNUNET_break (0 <= @@ -376,6 +388,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, "Unexpected type `%s' in response for exchange refund\n", type); GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } } @@ -393,6 +406,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &amount)) { GNUNET_break (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } } @@ -405,10 +419,12 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &rtotal)) { /* dtotal < rtotal: good! */ + GNUNET_JSON_parse_free (spec); return GNUNET_OK; } /* this fails to prove a conflict */ GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } @@ -422,14 +438,15 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, * @param json json reply with the signature * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not */ -static int +static enum GNUNET_GenericReturnValue verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, const json_t *json) { json_t *h; json_t *e; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("history", &h), + GNUNET_JSON_spec_json ("history", + &h), GNUNET_JSON_spec_end () }; @@ -445,6 +462,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, (1 != json_array_size (h) ) ) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } e = json_array_get (h, 0); @@ -459,7 +477,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, .coin_pub = rh->depconf.coin_pub }; uint64_t rtransaction_id; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { TALER_JSON_spec_amount_any ("amount", &amount), GNUNET_JSON_spec_string ("type", @@ -479,10 +497,11 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, if (GNUNET_OK != GNUNET_JSON_parse (e, - spec, + ispec, NULL, NULL)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } rr.rtransaction_id = GNUNET_htonll (rtransaction_id); @@ -495,6 +514,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, &rh->depconf.merchant.eddsa_pub)) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } if ( (rr.rtransaction_id != rh->depconf.rtransaction_id) || @@ -506,9 +526,11 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh, &rr.refund_amount)) ) { GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } } + GNUNET_JSON_parse_free (spec); return GNUNET_OK; } |