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);
json_array_append (transfer_pubs, GNUNET_assert (0 ==
GNUNET_JSON_from_data_auto (&transfer_pub)); json_array_append (transfer_pubs,
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));
json_array_append (secret_encs, GNUNET_assert (0 ==
GNUNET_JSON_from_data_auto (&els)); json_array_append (secret_encs,
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++)
{ {
json_array_append (new_denoms, GNUNET_assert (0 ==
GNUNET_JSON_from_rsa_public_key json_array_append (new_denoms,
(md->fresh_pks[i].rsa_public_key)); GNUNET_JSON_from_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);
json_array_append (tmp, GNUNET_assert (0 ==
GNUNET_JSON_from_data_auto (&rle)); json_array_append (tmp,
GNUNET_JSON_from_data_auto (&rle)));
} }
json_array_append (link_encs, GNUNET_assert (0 ==
tmp); json_array_append (link_encs,
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;
} }
json_array_append (tmp, GNUNET_assert (0 ==
GNUNET_JSON_from_data (coin_ev, json_array_append (tmp,
coin_ev_size)); GNUNET_JSON_from_data (coin_ev,
coin_ev_size)));
GNUNET_free (coin_ev); GNUNET_free (coin_ev);
} }
json_array_append (coin_evs, GNUNET_assert (0 ==
tmp); json_array_append (coin_evs,
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;
} }
json_array_append (transfer_privs, GNUNET_assert (0 ==
GNUNET_JSON_from_data_auto (&md->melted_coin.transfer_priv[j])); json_array_append (transfer_privs,
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);
json_array_append_new (ctx->denom_keys_array, GNUNET_assert (0 ==
denom_key_issue_to_json (&dki->denom_pub, json_array_append_new (ctx->denom_keys_array,
&dki->issue)); denom_key_issue_to_json (&dki->denom_pub,
&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;
} }
json_array_append_new (ctx->sign_keys_array, GNUNET_assert (0 ==
sign_key_issue_to_json (&ski->issue)); json_array_append_new (ctx->sign_keys_array,
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++)
json_array_append_new (ja, GNUNET_assert (0 ==
json_pack ("{s:o, s:o}", json_array_append_new (ja,
"denom_pub_h", json_pack ("{s:o, s:o}",
GNUNET_JSON_from_data_auto (&dki[i]->denom_hash), "denom_pub_h",
"auditor_sig", GNUNET_JSON_from_data_auto (&dki[i]->denom_hash),
GNUNET_JSON_from_data_auto (asigs[i]))); "auditor_sig",
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 */
json_array_append_new (ctx->auditors_array, GNUNET_assert (0 ==
auditor_to_json (apub, json_array_append_new (ctx->auditors_array,
auditor_url, auditor_to_json (apub,
keep, auditor_url,
kept_asigs, keep,
kept_dkis)); kept_asigs,
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);
} }
json_array_append_new (history, GNUNET_assert (0 ==
json_pack ("{s:s, s:o, s:o, s:o}", json_array_append_new (history,
"type", type, json_pack ("{s:s, s:o, s:o, s:o}",
"amount", TALER_JSON_from_amount (&value), "type", type,
"signature", GNUNET_JSON_from_data_auto (sig), "amount", TALER_JSON_from_amount (&value),
"details", details)); "signature", GNUNET_JSON_from_data_auto (sig),
"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;
json_array_append_new (json_history, GNUNET_assert (0 ==
json_pack ("{s:s, s:O, s:O, s:o}", json_array_append_new (json_history,
"type", "DEPOSIT", json_pack ("{s:s, s:O, s:O, s:o}",
"sender_account_details", pos->details.bank->sender_account_details, "type", "DEPOSIT",
"transfer_details", pos->details.bank->transfer_details, "sender_account_details", pos->details.bank->sender_account_details,
"amount", TALER_JSON_from_amount (&pos->details.bank->amount))); "transfer_details", pos->details.bank->transfer_details,
"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;
json_array_append_new (json_history, GNUNET_assert (0 ==
json_pack ("{s:s, s:o, s:o, s:o}", json_array_append_new (json_history,
"type", "WITHDRAW", json_pack ("{s:s, s:o, s:o, s:o}",
"signature", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig), "type", "WITHDRAW",
"details", GNUNET_JSON_from_data_auto (&wr), "signature", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig),
"amount", TALER_JSON_from_amount (&value))); "details", GNUNET_JSON_from_data_auto (&wr),
"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));
json_array_append_new (list, GNUNET_assert (0 ==
obj); json_array_append_new (list,
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];
json_array_append_new (info_new, GNUNET_assert (0 ==
GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key)); json_array_append_new (info_new,
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));
json_array_append_new (info_commit_k, GNUNET_assert (0 ==
cc_json); json_array_append_new (info_commit_k,
cc_json));
} }
json_array_append_new (info_commit, GNUNET_assert (0 ==
info_commit_k); json_array_append_new (info_commit,
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));
json_array_append_new (info_links, GNUNET_assert (0 ==
info_link_k); json_array_append_new (info_links,
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));
json_array_append_new (list, GNUNET_assert (0 ==
obj); json_array_append_new (list,
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));
json_array_append_new (mlist, GNUNET_assert (0 ==
root); json_array_append_new (mlist,
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));
json_array_append (deposits, GNUNET_assert (0 ==
json_pack ("{s:o, s:I, s:o, s:o, s:o}", json_array_append (deposits,
"H_contract", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract), json_pack ("{s:o, s:I, s:o, s:o, s:o}",
"transaction_id", (json_int_t) wdd_pos->transaction_id, "H_contract", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract),
"coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub), "transaction_id", (json_int_t) wdd_pos->transaction_id,
"deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), "coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub),
"deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee))); "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value),
"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));