diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-10-06 20:07:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-10-06 21:11:49 +0200 |
commit | e6a8b181f8e242e78c5c893c751d8ab179987fd2 (patch) | |
tree | 0a213101b5bb9ca3ade5b5bc2ba12ebceab5d067 | |
parent | b23781154ace70764e0c65efa1d49abba004dbf2 (diff) | |
download | merchant-e6a8b181f8e242e78c5c893c751d8ab179987fd2.tar.gz merchant-e6a8b181f8e242e78c5c893c751d8ab179987fd2.tar.bz2 merchant-e6a8b181f8e242e78c5c893c751d8ab179987fd2.zip |
check return value from TALER_JSON_hash
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 13 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 1 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 13 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_refund.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 15 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 3 | ||||
-rw-r--r-- | src/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 index 437537d5..15086cc2 100644 --- 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 index 600a9ac5..3c3d43d0 100644 --- 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 index 4cb6dc99..59bd62a8 100644 --- 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 index fc9e7a2a..ad4ff326 100644 --- 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 index 5101f3fd..7a4d0c06 100644 --- 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 index 249c0fab..7a33577c 100644 --- 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 index 683ebdd8..eb4fe14b 100644 --- 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, |