[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] 01/02: check return value from TALER_JSON_
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] 01/02: check return value from TALER_JSON_hash |
Date: |
Fri, 06 Oct 2017 21:11:53 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit e6a8b181f8e242e78c5c893c751d8ab179987fd2
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Oct 6 20:07:28 2017 +0200
check return value from TALER_JSON_hash
---
src/backend/taler-merchant-httpd.c | 13 +++++++------
src/backend/taler-merchant-httpd_pay.c | 1 +
src/backend/taler-merchant-httpd_proposal.c | 13 ++++++++++---
src/backend/taler-merchant-httpd_refund.c | 2 ++
src/backend/taler-merchant-httpd_track-transaction.c | 15 +++++++++++----
src/backenddb/plugin_merchantdb_postgres.c | 3 +++
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 437537d..15086cc 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 600a9ac..3c3d43d 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 4cb6dc9..59bd62a 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 fc9e7a2..ad4ff32 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 5101f3f..7a4d0c0 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 249c0fa..7a33577 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 683ebdd..eb4fe14 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,
--
To stop receiving notification emails like this one, please contact
address@hidden