merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit e6a8b181f8e242e78c5c893c751d8ab179987fd2
parent b23781154ace70764e0c65efa1d49abba004dbf2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  6 Oct 2017 20:07:28 +0200

check return value from TALER_JSON_hash

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 13+++++++------
Msrc/backend/taler-merchant-httpd_pay.c | 1+
Msrc/backend/taler-merchant-httpd_proposal.c | 13++++++++++---
Msrc/backend/taler-merchant-httpd_refund.c | 2++
Msrc/backend/taler-merchant-httpd_track-transaction.c | 15+++++++++++----
Msrc/backenddb/plugin_merchantdb_postgres.c | 3+++
Msrc/backenddb/test_merchantdb.c | 10++++++----
7 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -234,7 +234,7 @@ url_handler (void *cls, for (unsigned int i=0;NULL != handlers[i].url;i++) { struct TMH_RequestHandler *rh = &handlers[i]; - + if ( (0 == strcasecmp (url, rh->url)) && ( (NULL == rh->method) || @@ -564,20 +564,21 @@ instances_iterator_cb (void *cls, iic->ret |= GNUNET_SYSERR; } - if (GNUNET_YES != TALER_JSON_hash (mi->j_wire, - &mi->h_wire)) + if (GNUNET_OK != + TALER_JSON_hash (mi->j_wire, + &mi->h_wire)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to hash wireformat\n"); iic->ret |= GNUNET_SYSERR; } - #define EXTRADEBUG - #ifdef EXTRADEBUGG +#define EXTRADEBUG +#ifdef EXTRADEBUGG GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found wireformat instance:\n"); json_dumpf (mi->j_wire, stdout, 0); printf ("\n"); - #endif +#endif GNUNET_CRYPTO_hash (mi->id, strlen (mi->id), diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -1246,6 +1246,7 @@ parse_pay (struct MHD_Connection *connection, TALER_JSON_hash (pc->contract_terms, &pc->h_contract_terms)) { + GNUNET_break (0); GNUNET_JSON_parse_free (spec); if (MHD_YES != TMH_RESPONSE_reply_internal_error (connection, diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c @@ -293,9 +293,16 @@ proposal_put (struct MHD_Connection *connection, /* create proposal signature */ pdps.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT); pdps.purpose.size = htonl (sizeof (pdps)); - GNUNET_assert (GNUNET_OK == - TALER_JSON_hash (order, - &pdps.hash)); + if (GNUNET_OK != + TALER_JSON_hash (order, + &pdps.hash)) + { + GNUNET_break (0); + GNUNET_JSON_parse_free (spec); + return TMH_RESPONSE_reply_internal_error (connection, + TALER_EC_INTERNAL_LOGIC_ERROR, + "Could not hash order"); + } GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv, &pdps.purpose, diff --git a/src/backend/taler-merchant-httpd_refund.c b/src/backend/taler-merchant-httpd_refund.c @@ -210,6 +210,7 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh, TALER_JSON_hash (contract_terms, &h_contract_terms)) { + GNUNET_break (0); GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not hash contract terms\n"); @@ -456,6 +457,7 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh, TALER_JSON_hash (contract_terms, &h_contract_terms)) { + GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not hash contract terms\n"); return TMH_RESPONSE_reply_internal_error (connection, diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c @@ -481,7 +481,7 @@ wire_deposits_cb (void *cls, break; } if (0 > qs) - { + { /* Not good, but not fatal either, log error and continue */ /* Special report if retries insufficient */ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); @@ -1040,8 +1040,15 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_not_found (connection, TALER_EC_PROPOSAL_LOOKUP_NOT_FOUND, "Given order_id doesn't map to any proposal"); - TALER_JSON_hash (contract_terms, - &h_contract_terms); + if (GNUNET_OK != + TALER_JSON_hash (contract_terms, + &h_contract_terms)) + { + json_decref (contract_terms); + return TMH_RESPONSE_reply_internal_error (connection, + TALER_EC_INTERNAL_LOGIC_ERROR, + "Failed to hash contract terms"); + } json_decref (contract_terms); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1059,7 +1066,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_internal_error (connection, TALER_EC_TRACK_TRANSACTION_DB_FETCH_TRANSACTION_ERROR, "Database error finding transaction"); - } + } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -699,7 +699,10 @@ postgres_insert_contract_terms (void *cls, if (GNUNET_OK != TALER_JSON_hash (contract_terms, &h_contract_terms)) + { + GNUNET_break (0); return GNUNET_SYSERR; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "inserting contract_terms: order_id: %s, merchant_pub: %s, h_contract_terms: %s.\n", order_id, diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -599,8 +599,9 @@ run (void *cls) "order", json_string ("2"))); - TALER_JSON_hash (contract_terms, - &h_contract_terms); + GNUNET_assert (GNUNET_OK == + TALER_JSON_hash (contract_terms, + &h_contract_terms)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_contract_terms (plugin->cls, @@ -655,8 +656,9 @@ run (void *cls) fake_now = GNUNET_TIME_absolute_subtract (timestamp, delta); - TALER_JSON_hash (contract_terms_future, - &h_contract_terms_future); + GNUNET_assert (GNUNET_OK == + TALER_JSON_hash (contract_terms_future, + &h_contract_terms_future)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->mark_proposal_paid (plugin->cls,