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)
{
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);

View File

@ -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;

View File

@ -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));

View File

@ -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;
}

View File

@ -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,

View File

@ -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;i<kd->num_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;i<kd->num_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;i<kd->num_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;j<ai->num_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);
}