diff --git a/src/bank-lib/fakebank_history.c b/src/bank-lib/fakebank_history.c index a3553b65b..4cd0dc4cd 100644 --- a/src/bank-lib/fakebank_history.c +++ b/src/bank-lib/fakebank_history.c @@ -227,8 +227,9 @@ TFH_build_history_response (struct MHD_Connection *connection, while (NULL != history_element) { - json_array_append_new (history, - history_element->element); + GNUNET_assert (0 == + json_array_append_new (history, + history_element->element)); history_element = history_element->next; if (NULL != history_element) GNUNET_free_non_null (history_element->prev); diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 569283516..836e1cfc0 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -223,7 +223,7 @@ pick_exchange_account_cb (void *cls, strlen ("account-"))) { const char **s = cls; - + *s = section; } } @@ -376,12 +376,14 @@ run (void *cls, GNUNET_asprintf (&withdraw_fee_str, "%s:0.1", currency); - TALER_string_to_amount (withdraw_fee_str, - &withdraw_fee); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (withdraw_fee_str, + &withdraw_fee)); for (unsigned int i = 0; i < howmany_coins; i++) - TALER_amount_add (&total_reserve_amount, - &total_reserve_amount, - &withdraw_fee); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_reserve_amount, + &total_reserve_amount, + &withdraw_fee)); for (unsigned int j = 0; j < howmany_reserves; j++) { char *create_reserve_label; @@ -690,7 +692,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, GNUNET_OS_process_wait (exchanged); GNUNET_OS_process_destroy (exchanged); if (NULL != wirewatch) - { + { GNUNET_OS_process_kill (wirewatch, SIGTERM); GNUNET_OS_process_wait (wirewatch); @@ -968,7 +970,7 @@ main (int argc, _("Malformed payto:// URL `%s' in configuration\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); - return BAD_CONFIG_FILE; + return BAD_CONFIG_FILE; } GNUNET_free (exchange_payto_url); } diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 299b892fc..fda0ad509 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -704,8 +704,15 @@ deposit_cb (void *cls, GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; } - TALER_JSON_merchant_wire_signature_hash (wire, - &au->h_wire); + if (GNUNET_OK != + TALER_JSON_merchant_wire_signature_hash (wire, + &au->h_wire)) + { + GNUNET_break (0); + json_decref (au->wire); + au->wire = NULL; + return GNUNET_DB_STATUS_HARD_ERROR; + } GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &au->wtid, sizeof (au->wtid)); diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index 25de5f1fe..0aee1982c 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -366,9 +366,10 @@ refresh_reveal_transaction (void *cls, TALER_planchet_setup_refresh (&ts, j, &ps); - TALER_planchet_prepare (rcd->dk, - &ps, - &pd); + GNUNET_assert (GNUNET_OK == + TALER_planchet_prepare (rcd->dk, + &ps, + &pd)); rcd->coin_ev = pd.coin_ev; rcd->coin_ev_size = pd.coin_ev_size; } diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 731da36ce..73ce0e556 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -226,11 +226,12 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; - GNUNET_CRYPTO_kdf (&hc, sizeof (hc), - "salty", strlen ("salty"), - in_ptr, - in_ptr_size, - NULL, 0); + GNUNET_assert (GNUNET_YES == + GNUNET_CRYPTO_kdf (&hc, sizeof (hc), + "salty", strlen ("salty"), + in_ptr, + in_ptr_size, + NULL, 0)); GNUNET_JSON_parse_free (spec); json = GNUNET_JSON_from_data_auto (&hc); return TEH_RESPONSE_reply_json_pack (connection, diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 659301d41..ca4c13da7 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1593,6 +1593,11 @@ TALER_EXCHANGE_serialize_data now = GNUNET_TIME_absolute_get (); signkeys = json_array (); + if (NULL == signkeys) + { + GNUNET_break (0); + return NULL; + } for (unsigned int i=0;inum_sign_keys;i++) { const struct TALER_EXCHANGE_SigningPublicKey *sk = &kd->sign_keys[i]; @@ -1601,30 +1606,42 @@ TALER_EXCHANGE_serialize_data if (now.abs_value_us > sk->valid_until.abs_value_us) continue; /* skip keys that have expired */ signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "key", - GNUNET_JSON_from_data_auto - (&sk->key), - "master_sig", - GNUNET_JSON_from_data_auto - (&sk->master_sig), - "stamp_start", - GNUNET_JSON_from_time_abs - (sk->valid_from), - "stamp_expire", - GNUNET_JSON_from_time_abs - (sk->valid_until), - "stamp_end", - GNUNET_JSON_from_time_abs - (sk->valid_legal)); + "key", + GNUNET_JSON_from_data_auto + (&sk->key), + "master_sig", + GNUNET_JSON_from_data_auto + (&sk->master_sig), + "stamp_start", + GNUNET_JSON_from_time_abs + (sk->valid_from), + "stamp_expire", + GNUNET_JSON_from_time_abs + (sk->valid_until), + "stamp_end", + GNUNET_JSON_from_time_abs + (sk->valid_legal)); if (NULL == signkey) { GNUNET_break (0); continue; } - json_array_append_new (signkeys, - signkey); + if (0 != json_array_append_new (signkeys, + signkey)) + { + GNUNET_break (0); + json_decref (signkey); + json_decref (signkeys); + return NULL; + } } denoms = json_array (); + if (NULL == denoms) + { + GNUNET_break (0); + json_decref (signkeys); + return NULL; + } for (unsigned int i=0;inum_denom_keys;i++) { const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[i]; @@ -1633,41 +1650,55 @@ TALER_EXCHANGE_serialize_data if (now.abs_value_us > dk->expire_deposit.abs_value_us) continue; /* skip keys that have expired */ denom = json_pack ("{s:o, s:o, s:o, s:o, s:o " - ",s:o, s:o, s:o, s:o, s:o " - ",s:o}", - "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (dk->expire_deposit), - "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), - "stamp_start", - GNUNET_JSON_from_time_abs (dk->valid_from), - "stamp_expire_legal", - GNUNET_JSON_from_time_abs (dk->expire_legal), - "value", - TALER_JSON_from_amount (&dk->value), - "fee_withdraw", - /* #6 */ - TALER_JSON_from_amount (&dk->fee_withdraw), - "fee_deposit", - TALER_JSON_from_amount (&dk->fee_deposit), - "fee_refresh", - TALER_JSON_from_amount (&dk->fee_refresh), - "fee_refund", - TALER_JSON_from_amount (&dk->fee_refund), - "master_sig", - GNUNET_JSON_from_data_auto (&dk->master_sig), - /* #10 */ - "denom_pub", - GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key)); + ",s:o, s:o, s:o, s:o, s:o " + ",s:o}", + "stamp_expire_deposit", + GNUNET_JSON_from_time_abs (dk->expire_deposit), + "stamp_expire_withdraw", + GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), + "stamp_start", + GNUNET_JSON_from_time_abs (dk->valid_from), + "stamp_expire_legal", + GNUNET_JSON_from_time_abs (dk->expire_legal), + "value", + TALER_JSON_from_amount (&dk->value), + "fee_withdraw", + /* #6 */ + TALER_JSON_from_amount (&dk->fee_withdraw), + "fee_deposit", + TALER_JSON_from_amount (&dk->fee_deposit), + "fee_refresh", + TALER_JSON_from_amount (&dk->fee_refresh), + "fee_refund", + TALER_JSON_from_amount (&dk->fee_refund), + "master_sig", + GNUNET_JSON_from_data_auto (&dk->master_sig), + /* #10 */ + "denom_pub", + GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key)); if (NULL == denom) { GNUNET_break (0); continue; } - json_array_append_new (denoms, - denom); + if (0 == json_array_append_new (denoms, + denom)) + { + GNUNET_break (0); + json_decref (denom); + json_decref (denoms); + json_decref (signkeys); + return NULL; + } } auditors = json_array (); + if (NULL == auditors) + { + GNUNET_break (0); + json_decref (denoms); + json_decref (signkeys); + return NULL; + } for (unsigned int i=0;inum_auditors;i++) { const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; @@ -1675,6 +1706,14 @@ TALER_EXCHANGE_serialize_data json_t *adenoms; adenoms = json_array (); + if (NULL == adenoms) + { + GNUNET_break (0); + json_decref (denoms); + json_decref (signkeys); + json_decref (auditors); + return NULL; + } for (unsigned int j=0;jnum_denom_keys;j++) { const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = &ai->denom_keys[j]; @@ -1682,69 +1721,92 @@ TALER_EXCHANGE_serialize_data json_t *k; if (now.abs_value_us > dk->expire_deposit.abs_value_us) - continue; /* skip auditor signatures for denomination keys that have expired */ + continue; /* skip auditor signatures for denomination keys that have expired */ GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); k = json_pack ("{s:o, s:o}", - "denom_pub_h", - GNUNET_JSON_from_data_auto (&dk->h_key), - "auditor_sig", - GNUNET_JSON_from_data_auto (&adi->auditor_sig)); + "denom_pub_h", + GNUNET_JSON_from_data_auto (&dk->h_key), + "auditor_sig", + GNUNET_JSON_from_data_auto (&adi->auditor_sig)); if (NULL == k) { - GNUNET_break (0); - continue; + GNUNET_break (0); + json_decref (adenoms); + json_decref (denoms); + json_decref (signkeys); + json_decref (auditors); + return NULL; + } + if (0 != json_array_append_new (adenoms, + k)) + { + GNUNET_break (0); + json_decref (k); + json_decref (adenoms); + json_decref (denoms); + json_decref (signkeys); + json_decref (auditors); + return NULL; } - json_array_append_new (adenoms, - k); } a = json_pack ("{s:o, s:s, s:o}", - "auditor_pub", - GNUNET_JSON_from_data_auto (&ai->auditor_pub), - "auditor_url", - ai->auditor_url, - "denomination_keys", - adenoms); + "auditor_pub", + GNUNET_JSON_from_data_auto (&ai->auditor_pub), + "auditor_url", + ai->auditor_url, + "denomination_keys", + adenoms); if (NULL == a) { - GNUNET_break (0); - continue; + json_decref (adenoms); + json_decref (denoms); + json_decref (signkeys); + json_decref (auditors); + return NULL; + } + if (0 != json_array_append_new (auditors, + a)) + { + json_decref (a); + json_decref (denoms); + json_decref (signkeys); + json_decref (auditors); + return NULL; } - json_array_append_new (auditors, - a); } keys = json_pack ("{s:s, s:o, s:o, s:o, s:o" - ",s:o, s:o}", - /* 1 */ - "version", - kd->version, - "master_public_key", - GNUNET_JSON_from_data_auto (&kd->master_pub), - "reserve_closing_delay", - GNUNET_JSON_from_time_rel (kd->reserve_closing_delay), - "list_issue_date", - GNUNET_JSON_from_time_abs (kd->list_issue_date), - "signkeys", - signkeys, - /* #6 */ - "denoms", - denoms, - "auditors", - auditors); + ",s:o, s:o}", + /* 1 */ + "version", + kd->version, + "master_public_key", + GNUNET_JSON_from_data_auto (&kd->master_pub), + "reserve_closing_delay", + GNUNET_JSON_from_time_rel (kd->reserve_closing_delay), + "list_issue_date", + GNUNET_JSON_from_time_abs (kd->list_issue_date), + "signkeys", + signkeys, + /* #6 */ + "denoms", + denoms, + "auditors", + auditors); if (NULL == keys) { GNUNET_break (0); return NULL; } return json_pack ("{s:I, s:o, s:s, s:o}", - "version", - (json_int_t) TALER_SERIALIZATION_FORMAT_VERSION, - "expire", - GNUNET_JSON_from_time_abs (exchange->key_data_expiration), - "url", - exchange->url, - "keys", - keys); + "version", + (json_int_t) TALER_SERIALIZATION_FORMAT_VERSION, + "expire", + GNUNET_JSON_from_time_abs (exchange->key_data_expiration), + "url", + exchange->url, + "keys", + keys); }