check return value from TALER_JSON_hash

This commit is contained in:
Christian Grothoff 2017-10-06 20:02:28 +02:00
parent 1da03b95eb
commit 2f715c27f8
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
9 changed files with 92 additions and 47 deletions

View File

@ -2182,8 +2182,15 @@ check_wire_out_cb (void *cls,
wcc.date = date; wcc.date = date;
TALER_amount_get_zero (amount->currency, TALER_amount_get_zero (amount->currency,
&wcc.total_deposits); &wcc.total_deposits);
if (GNUNET_OK !=
TALER_JSON_hash (wire, TALER_JSON_hash (wire,
&wcc.h_wire); &wcc.h_wire))
{
report_row_inconsistency ("wire_out",
rowid,
"could not hash wire address");
return GNUNET_OK;
}
qs = edb->lookup_wire_transfer (edb->cls, qs = edb->lookup_wire_transfer (edb->cls,
esession, esession,
wtid, wtid,

View File

@ -883,8 +883,9 @@ spend_coin (struct Coin *coin,
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
dr.h_contract_terms = h_contract_terms; dr.h_contract_terms = h_contract_terms;
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (merchant_details, TALER_JSON_hash (merchant_details,
&dr.h_wire); &dr.h_wire));
dr.timestamp = GNUNET_TIME_absolute_hton (timestamp); dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);

View File

@ -415,9 +415,13 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
MAH_handle_is_ready (exchange)); MAH_handle_is_ready (exchange));
/* initialize h_wire */ /* initialize h_wire */
GNUNET_assert (GNUNET_OK == if (GNUNET_OK !=
TALER_JSON_hash (wire_details, TALER_JSON_hash (wire_details,
&h_wire)); &h_wire))
{
GNUNET_break (0);
return NULL;
}
key_state = TALER_EXCHANGE_get_keys (exchange); key_state = TALER_EXCHANGE_get_keys (exchange);
dki = TALER_EXCHANGE_get_denomination_key (key_state, dki = TALER_EXCHANGE_get_denomination_key (key_state,
denom_pub); denom_pub);

View File

@ -354,8 +354,13 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
} }
TALER_amount_hton (&rcc.closing_amount, TALER_amount_hton (&rcc.closing_amount,
&amount); &amount);
if (GNUNET_OK !=
TALER_JSON_hash (rhistory[off].details.close_details.receiver_account_details, TALER_JSON_hash (rhistory[off].details.close_details.receiver_account_details,
&rcc.h_wire); &rcc.h_wire))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
rcc.wtid = rhistory[off].details.close_details.wtid; rcc.wtid = rhistory[off].details.close_details.wtid;
rcc.purpose.size = htonl (sizeof (rcc)); rcc.purpose.size = htonl (sizeof (rcc));
rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED); rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED);

View File

@ -1709,8 +1709,9 @@ wire_deposits_cb (void *cls,
wire = json_loads (dep->details.deposit.wire_details, wire = json_loads (dep->details.deposit.wire_details,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire, TALER_JSON_hash (wire,
&hw); &hw));
json_decref (wire); json_decref (wire);
if (0 != memcmp (&hw, if (0 != memcmp (&hw,
h_wire, h_wire,
@ -2261,8 +2262,9 @@ interpreter_run (void *cls)
fail (is); fail (is);
return; return;
} }
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (contract_terms, TALER_JSON_hash (contract_terms,
&h_contract_terms); &h_contract_terms));
json_decref (contract_terms); json_decref (contract_terms);
wire = json_loads (cmd->details.deposit.wire_details, wire = json_loads (cmd->details.deposit.wire_details,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
@ -2307,8 +2309,9 @@ interpreter_run (void *cls)
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
dr.h_contract_terms = h_contract_terms; dr.h_contract_terms = h_contract_terms;
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire, TALER_JSON_hash (wire,
&dr.h_wire); &dr.h_wire));
dr.timestamp = GNUNET_TIME_absolute_hton (timestamp); dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
TALER_amount_hton (&dr.amount_with_fee, TALER_amount_hton (&dr.amount_with_fee,
@ -2542,15 +2545,17 @@ interpreter_run (void *cls)
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);
GNUNET_assert (NULL != wire); GNUNET_assert (NULL != wire);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire, TALER_JSON_hash (wire,
&h_wire); &h_wire));
json_decref (wire); json_decref (wire);
contract_terms = json_loads (ref->details.deposit.contract_terms, contract_terms = json_loads (ref->details.deposit.contract_terms,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);
GNUNET_assert (NULL != contract_terms); GNUNET_assert (NULL != contract_terms);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (contract_terms, TALER_JSON_hash (contract_terms,
&h_contract_terms); &h_contract_terms));
json_decref (contract_terms); json_decref (contract_terms);
cmd->details.deposit_wtid.dwh cmd->details.deposit_wtid.dwh
= TALER_EXCHANGE_track_transaction (exchange, = TALER_EXCHANGE_track_transaction (exchange,
@ -2665,8 +2670,9 @@ interpreter_run (void *cls)
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);
GNUNET_assert (NULL != contract_terms); GNUNET_assert (NULL != contract_terms);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (contract_terms, TALER_JSON_hash (contract_terms,
&h_contract_terms); &h_contract_terms));
json_decref (contract_terms); json_decref (contract_terms);
coin = find_command (is, coin = find_command (is,

View File

@ -611,8 +611,15 @@ deposit_cb (void *cls,
au->row_id = row_id; au->row_id = row_id;
GNUNET_assert (NULL == au->wire); GNUNET_assert (NULL == au->wire);
au->wire = json_incref ((json_t *) wire); au->wire = json_incref ((json_t *) wire);
if (GNUNET_OK !=
TALER_JSON_hash (au->wire, TALER_JSON_hash (au->wire,
&au->h_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

@ -718,6 +718,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
&deposit_total, &deposit_total,
&pos->details.bank->amount)) &pos->details.bank->amount))
{ {
GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
return NULL; return NULL;
} }
@ -748,6 +749,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
&withdraw_total, &withdraw_total,
&value)) &value))
{ {
GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
return NULL; return NULL;
} }
@ -782,6 +784,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
&deposit_total, &deposit_total,
&payback->value)) &payback->value))
{ {
GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
return NULL; return NULL;
} }
@ -840,8 +843,14 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
TALER_amount_hton (&rcc.closing_fee, TALER_amount_hton (&rcc.closing_fee,
&pos->details.closing->closing_fee); &pos->details.closing->closing_fee);
rcc.reserve_pub = pos->details.closing->reserve_pub; rcc.reserve_pub = pos->details.closing->reserve_pub;
if (GNUNET_OK !=
TALER_JSON_hash (pos->details.closing->receiver_account_details, TALER_JSON_hash (pos->details.closing->receiver_account_details,
&rcc.h_wire); &rcc.h_wire))
{
GNUNET_break (0);
json_decref (json_history);
return NULL;
}
rcc.wtid = pos->details.closing->wtid; rcc.wtid = pos->details.closing->wtid;
TEH_KS_sign (&rcc.purpose, TEH_KS_sign (&rcc.purpose,
&pub, &pub,

View File

@ -932,7 +932,9 @@ deposit_cb (void *cls,
deposit_rowid = rowid; deposit_rowid = rowid;
if (NULL != wire) if (NULL != wire)
TALER_JSON_hash (wire, &h_wire); GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire,
&h_wire));
if ( (0 != memcmp (merchant_pub, if ( (0 != memcmp (merchant_pub,
&deposit->merchant_pub, &deposit->merchant_pub,
sizeof (struct TALER_MerchantPublicKeyP))) || sizeof (struct TALER_MerchantPublicKeyP))) ||
@ -1776,8 +1778,9 @@ run (void *cls)
RND_BLK (&deposit.merchant_pub); RND_BLK (&deposit.merchant_pub);
RND_BLK (&deposit.h_contract_terms); RND_BLK (&deposit.h_contract_terms);
wire = json_loads (json_wire_str, 0, NULL); wire = json_loads (json_wire_str, 0, NULL);
GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire, TALER_JSON_hash (wire,
&deposit.h_wire); &deposit.h_wire));
deposit.receiver_wire_account = wire; deposit.receiver_wire_account = wire;
deposit.amount_with_fee = value; deposit.amount_with_fee = value;
deposit.deposit_fee = fee_deposit; deposit.deposit_fee = fee_deposit;

View File

@ -40,7 +40,10 @@ TALER_JSON_hash (const json_t *json,
if (NULL == (wire_enc = json_dumps (json, if (NULL == (wire_enc = json_dumps (json,
JSON_COMPACT | JSON_SORT_KEYS))) JSON_COMPACT | JSON_SORT_KEYS)))
{
GNUNET_break (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
}
len = strlen (wire_enc) + 1; len = strlen (wire_enc) + 1;
GNUNET_CRYPTO_hash (wire_enc, GNUNET_CRYPTO_hash (wire_enc,
len, len,