check more return values

This commit is contained in:
Christian Grothoff 2019-06-03 10:44:57 +02:00
parent 2cea0eb4d2
commit c241694ccb
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 183 additions and 109 deletions

View File

@ -227,8 +227,9 @@ TFH_build_history_response (struct MHD_Connection *connection,
while (NULL != history_element) while (NULL != history_element)
{ {
json_array_append_new (history, GNUNET_assert (0 ==
history_element->element); json_array_append_new (history,
history_element->element));
history_element = history_element->next; history_element = history_element->next;
if (NULL != history_element) if (NULL != history_element)
GNUNET_free_non_null (history_element->prev); GNUNET_free_non_null (history_element->prev);

View File

@ -376,12 +376,14 @@ run (void *cls,
GNUNET_asprintf (&withdraw_fee_str, GNUNET_asprintf (&withdraw_fee_str,
"%s:0.1", "%s:0.1",
currency); currency);
TALER_string_to_amount (withdraw_fee_str, GNUNET_assert (GNUNET_OK ==
&withdraw_fee); TALER_string_to_amount (withdraw_fee_str,
&withdraw_fee));
for (unsigned int i = 0; i < howmany_coins; i++) for (unsigned int i = 0; i < howmany_coins; i++)
TALER_amount_add (&total_reserve_amount, GNUNET_assert (GNUNET_OK ==
&total_reserve_amount, TALER_amount_add (&total_reserve_amount,
&withdraw_fee); &total_reserve_amount,
&withdraw_fee));
for (unsigned int j = 0; j < howmany_reserves; j++) for (unsigned int j = 0; j < howmany_reserves; j++)
{ {
char *create_reserve_label; char *create_reserve_label;

View File

@ -704,8 +704,15 @@ deposit_cb (void *cls,
GNUNET_break (0); GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
TALER_JSON_merchant_wire_signature_hash (wire, if (GNUNET_OK !=
&au->h_wire); 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, GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&au->wtid, &au->wtid,
sizeof (au->wtid)); sizeof (au->wtid));

View File

@ -366,9 +366,10 @@ refresh_reveal_transaction (void *cls,
TALER_planchet_setup_refresh (&ts, TALER_planchet_setup_refresh (&ts,
j, j,
&ps); &ps);
TALER_planchet_prepare (rcd->dk, GNUNET_assert (GNUNET_OK ==
&ps, TALER_planchet_prepare (rcd->dk,
&pd); &ps,
&pd));
rcd->coin_ev = pd.coin_ev; rcd->coin_ev = pd.coin_ev;
rcd->coin_ev_size = pd.coin_ev_size; rcd->coin_ev_size = pd.coin_ev_size;
} }

View File

@ -226,11 +226,12 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh,
json_decref (json); json_decref (json);
if (GNUNET_YES != res) if (GNUNET_YES != res)
return (GNUNET_NO == res) ? MHD_YES : MHD_NO; return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
GNUNET_CRYPTO_kdf (&hc, sizeof (hc), GNUNET_assert (GNUNET_YES ==
"salty", strlen ("salty"), GNUNET_CRYPTO_kdf (&hc, sizeof (hc),
in_ptr, "salty", strlen ("salty"),
in_ptr_size, in_ptr,
NULL, 0); in_ptr_size,
NULL, 0));
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
json = GNUNET_JSON_from_data_auto (&hc); json = GNUNET_JSON_from_data_auto (&hc);
return TEH_RESPONSE_reply_json_pack (connection, return TEH_RESPONSE_reply_json_pack (connection,

View File

@ -1593,6 +1593,11 @@ TALER_EXCHANGE_serialize_data
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
signkeys = json_array (); signkeys = json_array ();
if (NULL == signkeys)
{
GNUNET_break (0);
return NULL;
}
for (unsigned int i=0;i<kd->num_sign_keys;i++) for (unsigned int i=0;i<kd->num_sign_keys;i++)
{ {
const struct TALER_EXCHANGE_SigningPublicKey *sk = &kd->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) if (now.abs_value_us > sk->valid_until.abs_value_us)
continue; /* skip keys that have expired */ continue; /* skip keys that have expired */
signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}",
"key", "key",
GNUNET_JSON_from_data_auto GNUNET_JSON_from_data_auto
(&sk->key), (&sk->key),
"master_sig", "master_sig",
GNUNET_JSON_from_data_auto GNUNET_JSON_from_data_auto
(&sk->master_sig), (&sk->master_sig),
"stamp_start", "stamp_start",
GNUNET_JSON_from_time_abs GNUNET_JSON_from_time_abs
(sk->valid_from), (sk->valid_from),
"stamp_expire", "stamp_expire",
GNUNET_JSON_from_time_abs GNUNET_JSON_from_time_abs
(sk->valid_until), (sk->valid_until),
"stamp_end", "stamp_end",
GNUNET_JSON_from_time_abs GNUNET_JSON_from_time_abs
(sk->valid_legal)); (sk->valid_legal));
if (NULL == signkey) if (NULL == signkey)
{ {
GNUNET_break (0); GNUNET_break (0);
continue; continue;
} }
json_array_append_new (signkeys, if (0 != json_array_append_new (signkeys,
signkey); signkey))
{
GNUNET_break (0);
json_decref (signkey);
json_decref (signkeys);
return NULL;
}
} }
denoms = json_array (); denoms = json_array ();
if (NULL == denoms)
{
GNUNET_break (0);
json_decref (signkeys);
return NULL;
}
for (unsigned int i=0;i<kd->num_denom_keys;i++) for (unsigned int i=0;i<kd->num_denom_keys;i++)
{ {
const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->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) if (now.abs_value_us > dk->expire_deposit.abs_value_us)
continue; /* skip keys that have expired */ continue; /* skip keys that have expired */
denom = json_pack ("{s:o, s:o, s:o, s:o, s:o " 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, s:o, s:o, s:o, s:o "
",s:o}", ",s:o}",
"stamp_expire_deposit", "stamp_expire_deposit",
GNUNET_JSON_from_time_abs (dk->expire_deposit), GNUNET_JSON_from_time_abs (dk->expire_deposit),
"stamp_expire_withdraw", "stamp_expire_withdraw",
GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), GNUNET_JSON_from_time_abs (dk->withdraw_valid_until),
"stamp_start", "stamp_start",
GNUNET_JSON_from_time_abs (dk->valid_from), GNUNET_JSON_from_time_abs (dk->valid_from),
"stamp_expire_legal", "stamp_expire_legal",
GNUNET_JSON_from_time_abs (dk->expire_legal), GNUNET_JSON_from_time_abs (dk->expire_legal),
"value", "value",
TALER_JSON_from_amount (&dk->value), TALER_JSON_from_amount (&dk->value),
"fee_withdraw", "fee_withdraw",
/* #6 */ /* #6 */
TALER_JSON_from_amount (&dk->fee_withdraw), TALER_JSON_from_amount (&dk->fee_withdraw),
"fee_deposit", "fee_deposit",
TALER_JSON_from_amount (&dk->fee_deposit), TALER_JSON_from_amount (&dk->fee_deposit),
"fee_refresh", "fee_refresh",
TALER_JSON_from_amount (&dk->fee_refresh), TALER_JSON_from_amount (&dk->fee_refresh),
"fee_refund", "fee_refund",
TALER_JSON_from_amount (&dk->fee_refund), TALER_JSON_from_amount (&dk->fee_refund),
"master_sig", "master_sig",
GNUNET_JSON_from_data_auto (&dk->master_sig), GNUNET_JSON_from_data_auto (&dk->master_sig),
/* #10 */ /* #10 */
"denom_pub", "denom_pub",
GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key)); GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key));
if (NULL == denom) if (NULL == denom)
{ {
GNUNET_break (0); GNUNET_break (0);
continue; continue;
} }
json_array_append_new (denoms, if (0 == json_array_append_new (denoms,
denom); denom))
{
GNUNET_break (0);
json_decref (denom);
json_decref (denoms);
json_decref (signkeys);
return NULL;
}
} }
auditors = json_array (); auditors = json_array ();
if (NULL == auditors)
{
GNUNET_break (0);
json_decref (denoms);
json_decref (signkeys);
return NULL;
}
for (unsigned int i=0;i<kd->num_auditors;i++) for (unsigned int i=0;i<kd->num_auditors;i++)
{ {
const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i];
@ -1675,6 +1706,14 @@ TALER_EXCHANGE_serialize_data
json_t *adenoms; json_t *adenoms;
adenoms = json_array (); 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;j<ai->num_denom_keys;j++) for (unsigned int j=0;j<ai->num_denom_keys;j++)
{ {
const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = &ai->denom_keys[j]; const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = &ai->denom_keys[j];
@ -1682,69 +1721,92 @@ TALER_EXCHANGE_serialize_data
json_t *k; json_t *k;
if (now.abs_value_us > dk->expire_deposit.abs_value_us) 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); GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys);
k = json_pack ("{s:o, s:o}", k = json_pack ("{s:o, s:o}",
"denom_pub_h", "denom_pub_h",
GNUNET_JSON_from_data_auto (&dk->h_key), GNUNET_JSON_from_data_auto (&dk->h_key),
"auditor_sig", "auditor_sig",
GNUNET_JSON_from_data_auto (&adi->auditor_sig)); GNUNET_JSON_from_data_auto (&adi->auditor_sig));
if (NULL == k) if (NULL == k)
{ {
GNUNET_break (0); GNUNET_break (0);
continue; 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}", a = json_pack ("{s:o, s:s, s:o}",
"auditor_pub", "auditor_pub",
GNUNET_JSON_from_data_auto (&ai->auditor_pub), GNUNET_JSON_from_data_auto (&ai->auditor_pub),
"auditor_url", "auditor_url",
ai->auditor_url, ai->auditor_url,
"denomination_keys", "denomination_keys",
adenoms); adenoms);
if (NULL == a) if (NULL == a)
{ {
GNUNET_break (0); json_decref (adenoms);
continue; 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" keys = json_pack ("{s:s, s:o, s:o, s:o, s:o"
",s:o, s:o}", ",s:o, s:o}",
/* 1 */ /* 1 */
"version", "version",
kd->version, kd->version,
"master_public_key", "master_public_key",
GNUNET_JSON_from_data_auto (&kd->master_pub), GNUNET_JSON_from_data_auto (&kd->master_pub),
"reserve_closing_delay", "reserve_closing_delay",
GNUNET_JSON_from_time_rel (kd->reserve_closing_delay), GNUNET_JSON_from_time_rel (kd->reserve_closing_delay),
"list_issue_date", "list_issue_date",
GNUNET_JSON_from_time_abs (kd->list_issue_date), GNUNET_JSON_from_time_abs (kd->list_issue_date),
"signkeys", "signkeys",
signkeys, signkeys,
/* #6 */ /* #6 */
"denoms", "denoms",
denoms, denoms,
"auditors", "auditors",
auditors); auditors);
if (NULL == keys) if (NULL == keys)
{ {
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }
return json_pack ("{s:I, s:o, s:s, s:o}", return json_pack ("{s:I, s:o, s:s, s:o}",
"version", "version",
(json_int_t) TALER_SERIALIZATION_FORMAT_VERSION, (json_int_t) TALER_SERIALIZATION_FORMAT_VERSION,
"expire", "expire",
GNUNET_JSON_from_time_abs (exchange->key_data_expiration), GNUNET_JSON_from_time_abs (exchange->key_data_expiration),
"url", "url",
exchange->url, exchange->url,
"keys", "keys",
keys); keys);
} }