check return values of json_array_append

This commit is contained in:
Christian Grothoff 2016-06-11 13:54:11 +02:00
parent 5d28c01900
commit 7dc075ae28
3 changed files with 97 additions and 74 deletions

View File

@ -1317,8 +1317,9 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_CRYPTO_ecdhe_key_get_public (&mc->transfer_priv[j].ecdhe_priv, GNUNET_CRYPTO_ecdhe_key_get_public (&mc->transfer_priv[j].ecdhe_priv,
&transfer_pub.ecdhe_pub); &transfer_pub.ecdhe_pub);
GNUNET_assert (0 ==
json_array_append (transfer_pubs, json_array_append (transfer_pubs,
GNUNET_JSON_from_data_auto (&transfer_pub)); GNUNET_JSON_from_data_auto (&transfer_pub)));
} }
/* now secret_encs */ /* now secret_encs */
@ -1335,16 +1336,18 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
TALER_transfer_encrypt (&md->link_secrets[j], TALER_transfer_encrypt (&md->link_secrets[j],
&trans_sec, &trans_sec,
&els)); &els));
GNUNET_assert (0 ==
json_array_append (secret_encs, json_array_append (secret_encs,
GNUNET_JSON_from_data_auto (&els)); GNUNET_JSON_from_data_auto (&els)));
} }
/* now new_denoms */ /* now new_denoms */
for (i=0;i<md->num_fresh_coins;i++) for (i=0;i<md->num_fresh_coins;i++)
{ {
GNUNET_assert (0 ==
json_array_append (new_denoms, json_array_append (new_denoms,
GNUNET_JSON_from_rsa_public_key GNUNET_JSON_from_rsa_public_key
(md->fresh_pks[i].rsa_public_key)); (md->fresh_pks[i].rsa_public_key)));
} }
/* now link_encs */ /* now link_encs */
@ -1362,11 +1365,13 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
TALER_refresh_encrypt (&rld, TALER_refresh_encrypt (&rld,
&md->link_secrets[j], &md->link_secrets[j],
&rle); &rle);
GNUNET_assert (0 ==
json_array_append (tmp, json_array_append (tmp,
GNUNET_JSON_from_data_auto (&rle)); GNUNET_JSON_from_data_auto (&rle)));
} }
GNUNET_assert (0 ==
json_array_append (link_encs, json_array_append (link_encs,
tmp); tmp));
} }
/* now coin_evs */ /* now coin_evs */
@ -1404,13 +1409,15 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
json_decref (link_encs); json_decref (link_encs);
return NULL; return NULL;
} }
GNUNET_assert (0 ==
json_array_append (tmp, json_array_append (tmp,
GNUNET_JSON_from_data (coin_ev, GNUNET_JSON_from_data (coin_ev,
coin_ev_size)); coin_ev_size)));
GNUNET_free (coin_ev); GNUNET_free (coin_ev);
} }
GNUNET_assert (0 ==
json_array_append (coin_evs, json_array_append (coin_evs,
tmp); tmp));
} }
/* finally, assemble main JSON request from constitutent arrays */ /* finally, assemble main JSON request from constitutent arrays */
@ -1788,8 +1795,9 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,
noreval index! */ noreval index! */
continue; continue;
} }
GNUNET_assert (0 ==
json_array_append (transfer_privs, json_array_append (transfer_privs,
GNUNET_JSON_from_data_auto (&md->melted_coin.transfer_priv[j])); GNUNET_JSON_from_data_auto (&md->melted_coin.transfer_priv[j])));
} }
/* build main JSON request */ /* build main JSON request */

View File

@ -347,9 +347,10 @@ reload_keys_denom_iter (void *cls,
} }
ctx->min_dk_expire = GNUNET_TIME_absolute_min (ctx->min_dk_expire, ctx->min_dk_expire = GNUNET_TIME_absolute_min (ctx->min_dk_expire,
expire_deposit); expire_deposit);
GNUNET_assert (0 ==
json_array_append_new (ctx->denom_keys_array, json_array_append_new (ctx->denom_keys_array,
denom_key_issue_to_json (&dki->denom_pub, denom_key_issue_to_json (&dki->denom_pub,
&dki->issue)); &dki->issue)));
return GNUNET_OK; return GNUNET_OK;
} }
@ -436,8 +437,9 @@ reload_keys_sign_iter (void *cls,
/* We use the most recent one, if it is valid now (not just in the near future) */ /* We use the most recent one, if it is valid now (not just in the near future) */
ctx->current_sign_key_issue = *ski; ctx->current_sign_key_issue = *ski;
} }
GNUNET_assert (0 ==
json_array_append_new (ctx->sign_keys_array, json_array_append_new (ctx->sign_keys_array,
sign_key_issue_to_json (&ski->issue)); sign_key_issue_to_json (&ski->issue)));
return GNUNET_OK; return GNUNET_OK;
} }
@ -465,12 +467,13 @@ auditor_to_json (const struct TALER_AuditorPublicKeyP *apub,
ja = json_array (); ja = json_array ();
for (i=0;i<dki_len;i++) for (i=0;i<dki_len;i++)
GNUNET_assert (0 ==
json_array_append_new (ja, json_array_append_new (ja,
json_pack ("{s:o, s:o}", json_pack ("{s:o, s:o}",
"denom_pub_h", "denom_pub_h",
GNUNET_JSON_from_data_auto (&dki[i]->denom_hash), GNUNET_JSON_from_data_auto (&dki[i]->denom_hash),
"auditor_sig", "auditor_sig",
GNUNET_JSON_from_data_auto (asigs[i]))); GNUNET_JSON_from_data_auto (asigs[i]))));
return return
json_pack ("{s:o, s:s, s:o}", json_pack ("{s:o, s:s, s:o}",
"denomination_keys", ja, "denomination_keys", ja,
@ -536,12 +539,13 @@ reload_auditor_iter (void *cls,
} }
} }
/* add auditor information to our /keys response */ /* add auditor information to our /keys response */
GNUNET_assert (0 ==
json_array_append_new (ctx->auditors_array, json_array_append_new (ctx->auditors_array,
auditor_to_json (apub, auditor_to_json (apub,
auditor_url, auditor_url,
keep, keep,
kept_asigs, kept_asigs,
kept_dkis)); kept_dkis)));
return GNUNET_OK; return GNUNET_OK;
} }

View File

@ -526,12 +526,13 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
default: default:
GNUNET_assert (0); GNUNET_assert (0);
} }
GNUNET_assert (0 ==
json_array_append_new (history, json_array_append_new (history,
json_pack ("{s:s, s:o, s:o, s:o}", json_pack ("{s:s, s:o, s:o, s:o}",
"type", type, "type", type,
"amount", TALER_JSON_from_amount (&value), "amount", TALER_JSON_from_amount (&value),
"signature", GNUNET_JSON_from_data_auto (sig), "signature", GNUNET_JSON_from_data_auto (sig),
"details", details)); "details", details)));
} }
return history; return history;
} }
@ -602,12 +603,13 @@ compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh,
return NULL; return NULL;
} }
ret = 1; ret = 1;
GNUNET_assert (0 ==
json_array_append_new (json_history, json_array_append_new (json_history,
json_pack ("{s:s, s:O, s:O, s:o}", json_pack ("{s:s, s:O, s:O, s:o}",
"type", "DEPOSIT", "type", "DEPOSIT",
"sender_account_details", pos->details.bank->sender_account_details, "sender_account_details", pos->details.bank->sender_account_details,
"transfer_details", pos->details.bank->transfer_details, "transfer_details", pos->details.bank->transfer_details,
"amount", TALER_JSON_from_amount (&pos->details.bank->amount))); "amount", TALER_JSON_from_amount (&pos->details.bank->amount))));
break; break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN: case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
break; break;
@ -649,12 +651,13 @@ compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh,
GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key,
&wr.h_denomination_pub); &wr.h_denomination_pub);
wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope; wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope;
GNUNET_assert (0 ==
json_array_append_new (json_history, json_array_append_new (json_history,
json_pack ("{s:s, s:o, s:o, s:o}", json_pack ("{s:s, s:o, s:o, s:o}",
"type", "WITHDRAW", "type", "WITHDRAW",
"signature", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig), "signature", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig),
"details", GNUNET_JSON_from_data_auto (&wr), "details", GNUNET_JSON_from_data_auto (&wr),
"amount", TALER_JSON_from_amount (&value))); "amount", TALER_JSON_from_amount (&value))));
break; break;
} }
} }
@ -947,8 +950,9 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
json_object_set_new (obj, json_object_set_new (obj,
"ev_sig", "ev_sig",
GNUNET_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature)); GNUNET_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature));
GNUNET_assert (0 ==
json_array_append_new (list, json_array_append_new (list,
obj); obj));
} }
root = json_object (); root = json_object ();
json_object_set_new (root, json_object_set_new (root,
@ -1012,8 +1016,9 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
const struct TALER_DenominationPublicKey *pk; const struct TALER_DenominationPublicKey *pk;
pk = &mc->denom_pubs[i]; pk = &mc->denom_pubs[i];
GNUNET_assert (0 ==
json_array_append_new (info_new, json_array_append_new (info_new,
GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key)); GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key)));
} }
info_commit = json_array (); info_commit = json_array ();
@ -1043,11 +1048,13 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
"blinding_key_enc", "blinding_key_enc",
GNUNET_JSON_from_data_auto (&cc->refresh_link.blinding_key_enc)); GNUNET_JSON_from_data_auto (&cc->refresh_link.blinding_key_enc));
GNUNET_assert (0 ==
json_array_append_new (info_commit_k, json_array_append_new (info_commit_k,
cc_json); cc_json));
} }
GNUNET_assert (0 ==
json_array_append_new (info_commit, json_array_append_new (info_commit,
info_commit_k); info_commit_k));
info_link_k = json_object (); info_link_k = json_object ();
cl = &mc->commit_links[k]; cl = &mc->commit_links[k];
@ -1057,8 +1064,9 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
json_object_set_new (info_link_k, json_object_set_new (info_link_k,
"shared_secret_enc", "shared_secret_enc",
GNUNET_JSON_from_data_auto (&cl->shared_secret_enc)); GNUNET_JSON_from_data_auto (&cl->shared_secret_enc));
GNUNET_assert (0 ==
json_array_append_new (info_links, json_array_append_new (info_links,
info_link_k); info_link_k));
} }
return TMH_RESPONSE_reply_json_pack (connection, return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
@ -1113,8 +1121,9 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
json_object_set_new (obj, json_object_set_new (obj,
"ev_sig", "ev_sig",
GNUNET_JSON_from_rsa_signature (pos->ev_sig.rsa_signature)); GNUNET_JSON_from_rsa_signature (pos->ev_sig.rsa_signature));
GNUNET_assert (0 ==
json_array_append_new (list, json_array_append_new (list,
obj); obj));
} }
root = json_object (); root = json_object ();
json_object_set_new (root, json_object_set_new (root,
@ -1126,8 +1135,9 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
json_object_set_new (root, json_object_set_new (root,
"secret_enc", "secret_enc",
GNUNET_JSON_from_data_auto (&sessions[i].shared_secret_enc)); GNUNET_JSON_from_data_auto (&sessions[i].shared_secret_enc));
GNUNET_assert (0 ==
json_array_append_new (mlist, json_array_append_new (mlist,
root); root));
} }
res = TMH_RESPONSE_reply_json (connection, res = TMH_RESPONSE_reply_json (connection,
mlist, mlist,
@ -1267,13 +1277,14 @@ TMH_RESPONSE_reply_track_transfer_details (struct MHD_Connection *connection,
GNUNET_CRYPTO_hash_context_read (hash_context, GNUNET_CRYPTO_hash_context_read (hash_context,
&dd, &dd,
sizeof (struct TALER_WireDepositDetailP)); sizeof (struct TALER_WireDepositDetailP));
GNUNET_assert (0 ==
json_array_append (deposits, json_array_append (deposits,
json_pack ("{s:o, s:I, s:o, s:o, s:o}", json_pack ("{s:o, s:I, s:o, s:o, s:o}",
"H_contract", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract), "H_contract", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract),
"transaction_id", (json_int_t) wdd_pos->transaction_id, "transaction_id", (json_int_t) wdd_pos->transaction_id,
"coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub), "coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub),
"deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value),
"deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee))); "deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee))));
} }
wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT); wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT);
wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS)); wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS));