diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-24 20:37:23 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-24 20:37:23 +0200 |
commit | 079ef7cb6f911d97a796acf621d2f1212dc9c282 (patch) | |
tree | 181d9e7485dd8916c795569e642010f81d2bbf02 /src | |
parent | f471cfcec5aaa7283ce0d6f61b2a321d101efff0 (diff) |
fixing #4520: be more aggressive at asserting when API is violated
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange-lib/exchange_api_deposit.c | 51 | ||||
-rw-r--r-- | src/exchange-lib/exchange_api_refresh.c | 28 | ||||
-rw-r--r-- | src/exchange-lib/exchange_api_refund.c | 8 |
3 files changed, 27 insertions, 60 deletions
diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c index 6ddfe6f65..f8c8367ea 100644 --- a/src/exchange-lib/exchange_api_deposit.c +++ b/src/exchange-lib/exchange_api_deposit.c @@ -406,42 +406,21 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, (void) GNUNET_TIME_round_abs (&wire_deadline); (void) GNUNET_TIME_round_abs (&refund_deadline); - if (refund_deadline.abs_value_us > wire_deadline.abs_value_us) - { - GNUNET_break (0); - return NULL; - } - if (GNUNET_YES != - MAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } + GNUNET_assert (refund_deadline.abs_value_us <= wire_deadline.abs_value_us); + GNUNET_assert (GNUNET_YES == + MAH_handle_is_ready (exchange)); /* initialize h_wire */ - if (GNUNET_OK != - TALER_JSON_hash (wire_details, - &h_wire)) - { - GNUNET_break (0); - return NULL; - } + GNUNET_assert (GNUNET_OK == + TALER_JSON_hash (wire_details, + &h_wire)); key_state = TALER_EXCHANGE_get_keys (exchange); dki = TALER_EXCHANGE_get_denomination_key (key_state, denom_pub); - if (NULL == dki) - { - TALER_LOG_WARNING ("Denomination key unknown to exchange\n"); - return NULL; - } - if (GNUNET_SYSERR == - TALER_amount_subtract (&amount_without_fee, - amount, - &dki->fee_deposit)) - { - GNUNET_break (0); - return NULL; - } - + GNUNET_assert (NULL != dki); + GNUNET_assert (GNUNET_SYSERR != + TALER_amount_subtract (&amount_without_fee, + amount, + &dki->fee_deposit)); if (GNUNET_OK != verify_signatures (dki, amount, @@ -523,10 +502,10 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, strlen (dh->json_enc))); ctx = MAH_handle_to_context (exchange); dh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_YES, - &handle_deposit_finished, - dh); + eh, + GNUNET_YES, + &handle_deposit_finished, + dh); return dh; } diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c index 5f519a684..7e207d795 100644 --- a/src/exchange-lib/exchange_api_refresh.c +++ b/src/exchange-lib/exchange_api_refresh.c @@ -1277,12 +1277,8 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, unsigned int i; unsigned int j; - if (GNUNET_YES != - MAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } + GNUNET_assert (GNUNET_YES == + MAH_handle_is_ready (exchange)); md = deserialize_melt_data (refresh_data, refresh_data_length); if (NULL == md) @@ -1722,11 +1718,11 @@ handle_refresh_reveal_finished (void *cls, */ struct TALER_EXCHANGE_RefreshRevealHandle * TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, - size_t refresh_data_length, - const char *refresh_data, - uint16_t noreveal_index, - TALER_EXCHANGE_RefreshRevealCallback reveal_cb, - void *reveal_cb_cls) + size_t refresh_data_length, + const char *refresh_data, + uint16_t noreveal_index, + TALER_EXCHANGE_RefreshRevealCallback reveal_cb, + void *reveal_cb_cls) { struct TALER_EXCHANGE_RefreshRevealHandle *rrh; json_t *transfer_privs; @@ -1735,13 +1731,9 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx; struct MeltData *md; unsigned int j; - - if (GNUNET_YES != - MAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } + + GNUNET_assert (GNUNET_YES == + MAH_handle_is_ready (exchange)); md = deserialize_melt_data (refresh_data, refresh_data_length); if (NULL == md) diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c index 3a840c7c4..d622ddc75 100644 --- a/src/exchange-lib/exchange_api_refund.c +++ b/src/exchange-lib/exchange_api_refund.c @@ -243,12 +243,8 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, json_t *refund_obj; CURL *eh; - if (GNUNET_YES != - MAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } + GNUNET_assert (GNUNET_YES == + MAH_handle_is_ready (exchange)); rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); rr.h_contract = *h_contract; |