summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-19 11:43:40 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-19 11:43:40 +0100
commit61c6cb27442aed0b45cf31f8a69183b1c39e9a13 (patch)
tree0bd4be7427bc0fcff3dcad24ab55480c93a03a24
parent39e6ebbc169a250b6ae11928f5ce58696f09f19f (diff)
downloadmerchant-61c6cb27442aed0b45cf31f8a69183b1c39e9a13.tar.gz
merchant-61c6cb27442aed0b45cf31f8a69183b1c39e9a13.tar.bz2
merchant-61c6cb27442aed0b45cf31f8a69183b1c39e9a13.zip
-fix misc bugs
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-claim.c22
-rw-r--r--src/backend/taler-merchant-httpd_spa.c8
-rw-r--r--src/lib/merchant_api_lock_product.c2
-rw-r--r--src/lib/merchant_api_patch_instance.c2
-rw-r--r--src/lib/merchant_api_patch_order_forget.c2
-rw-r--r--src/lib/merchant_api_patch_product.c2
-rw-r--r--src/lib/merchant_api_post_instance_auth.c1
-rw-r--r--src/lib/merchant_api_post_instances.c2
-rw-r--r--src/lib/merchant_api_post_order_abort.c1
-rw-r--r--src/lib/merchant_api_post_order_paid.c2
-rw-r--r--src/lib/merchant_api_post_order_pay.c1
-rw-r--r--src/lib/merchant_api_post_order_refund.c1
-rw-r--r--src/lib/merchant_api_post_orders.c8
-rw-r--r--src/lib/merchant_api_post_reserves.c8
-rw-r--r--src/lib/merchant_api_post_transfers.c8
-rw-r--r--src/lib/merchant_api_tip_authorize.c9
-rw-r--r--src/lib/merchant_api_wallet_post_order_refund.c1
-rw-r--r--src/testing/testing_api_cmd_post_orders.c16
18 files changed, 70 insertions, 26 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
index 17475c9a..089933ea 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
@@ -62,7 +62,6 @@ claim_order (const char *instance_id,
struct TALER_ClaimTokenP order_ct;
enum GNUNET_DB_QueryStatus qs;
uint64_t order_serial;
- struct GNUNET_TIME_Absolute timestamp;
if (GNUNET_OK !=
TMH_db->start (TMH_db->cls,
@@ -90,8 +89,6 @@ claim_order (const char *instance_id,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("nonce",
&stored_nonce),
- TALER_JSON_spec_absolute_time ("timestamp",
- &timestamp),
GNUNET_JSON_spec_end ()
};
@@ -126,6 +123,12 @@ claim_order (const char *instance_id,
{
struct GNUNET_HashCode unused;
+ struct GNUNET_TIME_Absolute timestamp;
+ struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_absolute_time ("timestamp",
+ &timestamp),
+ GNUNET_JSON_spec_end ()
+ };
/* see if we have this order in our table of unclaimed orders */
qs = TMH_db->lookup_order (TMH_db->cls,
@@ -140,6 +143,19 @@ claim_order (const char *instance_id,
return qs;
}
GNUNET_assert (NULL != *contract_terms);
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (*contract_terms,
+ spec,
+ NULL,
+ NULL))
+ {
+ /* this should not be possible: contract_terms should always
+ have a timestamp! */
+ GNUNET_break (0);
+ TMH_db->rollback (TMH_db->cls);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+
GNUNET_assert (0 ==
json_object_set_new (*contract_terms,
"nonce",
diff --git a/src/backend/taler-merchant-httpd_spa.c b/src/backend/taler-merchant-httpd_spa.c
index 0e15ad4c..d36168c1 100644
--- a/src/backend/taler-merchant-httpd_spa.c
+++ b/src/backend/taler-merchant-httpd_spa.c
@@ -39,8 +39,8 @@ static struct MHD_Response *spa;
MHD_RESULT
TMH_return_spa (const struct TMH_RequestHandler *rh,
- struct MHD_Connection *connection,
- struct TMH_HandlerContext *hc)
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc)
{
if ( (MHD_YES ==
TALER_MHD_can_compress (connection)) &&
@@ -152,6 +152,10 @@ TMH_spa_init ()
"text/html"));
}
}
+ else
+ {
+ GNUNET_free (in);
+ }
}
spa = MHD_create_response_from_fd (sb.st_size,
diff --git a/src/lib/merchant_api_lock_product.c b/src/lib/merchant_api_lock_product.c
index 3a3caaeb..c8aaf22f 100644
--- a/src/lib/merchant_api_lock_product.c
+++ b/src/lib/merchant_api_lock_product.c
@@ -202,12 +202,14 @@ TALER_MERCHANT_product_lock (
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&plh->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (plh);
return NULL;
diff --git a/src/lib/merchant_api_patch_instance.c b/src/lib/merchant_api_patch_instance.c
index 810eff72..139d6966 100644
--- a/src/lib/merchant_api_patch_instance.c
+++ b/src/lib/merchant_api_patch_instance.c
@@ -243,12 +243,14 @@ TALER_MERCHANT_instance_patch (
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&iph->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (iph->url);
GNUNET_free (iph);
diff --git a/src/lib/merchant_api_patch_order_forget.c b/src/lib/merchant_api_patch_order_forget.c
index e6a36ad4..b8f5c22f 100644
--- a/src/lib/merchant_api_patch_order_forget.c
+++ b/src/lib/merchant_api_patch_order_forget.c
@@ -207,12 +207,14 @@ TALER_MERCHANT_order_forget (struct GNUNET_CURL_Context *ctx,
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&ofh->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (ofh);
return NULL;
diff --git a/src/lib/merchant_api_patch_product.c b/src/lib/merchant_api_patch_product.c
index da0e41ed..bec9f92d 100644
--- a/src/lib/merchant_api_patch_product.c
+++ b/src/lib/merchant_api_patch_product.c
@@ -224,12 +224,14 @@ TALER_MERCHANT_product_patch (
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&pph->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (pph);
return NULL;
diff --git a/src/lib/merchant_api_post_instance_auth.c b/src/lib/merchant_api_post_instance_auth.c
index 870448b7..382e9c42 100644
--- a/src/lib/merchant_api_post_instance_auth.c
+++ b/src/lib/merchant_api_post_instance_auth.c
@@ -194,6 +194,7 @@ TALER_MERCHANT_instance_auth_post (
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (iaph->url);
GNUNET_free (iaph);
diff --git a/src/lib/merchant_api_post_instances.c b/src/lib/merchant_api_post_instances.c
index df8a97f5..0fa7063f 100644
--- a/src/lib/merchant_api_post_instances.c
+++ b/src/lib/merchant_api_post_instances.c
@@ -269,12 +269,14 @@ TALER_MERCHANT_instances_post (
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&iph->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (iph);
return NULL;
diff --git a/src/lib/merchant_api_post_order_abort.c b/src/lib/merchant_api_post_order_abort.c
index e179ade5..2df7ca1c 100644
--- a/src/lib/merchant_api_post_order_abort.c
+++ b/src/lib/merchant_api_post_order_abort.c
@@ -411,6 +411,7 @@ TALER_MERCHANT_order_abort (struct GNUNET_CURL_Context *ctx,
abort_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (abort_obj);
GNUNET_free (oah);
return NULL;
diff --git a/src/lib/merchant_api_post_order_paid.c b/src/lib/merchant_api_post_order_paid.c
index 8e9cf9ac..fb58205a 100644
--- a/src/lib/merchant_api_post_order_paid.c
+++ b/src/lib/merchant_api_post_order_paid.c
@@ -207,12 +207,14 @@ TALER_MERCHANT_order_paid (
CURL *eh;
eh = curl_easy_init ();
+ GNUNET_assert (NULL != eh);
if (GNUNET_OK !=
TALER_curl_easy_post (&oph->post_ctx,
eh,
req_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req_obj);
GNUNET_free (oph);
return NULL;
diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c
index 08f041d4..158fa322 100644
--- a/src/lib/merchant_api_post_order_pay.c
+++ b/src/lib/merchant_api_post_order_pay.c
@@ -548,6 +548,7 @@ TALER_MERCHANT_order_pay_frontend (
pay_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (pay_obj);
GNUNET_free (oph);
return NULL;
diff --git a/src/lib/merchant_api_post_order_refund.c b/src/lib/merchant_api_post_order_refund.c
index e6104285..0678e3fd 100644
--- a/src/lib/merchant_api_post_order_refund.c
+++ b/src/lib/merchant_api_post_order_refund.c
@@ -229,6 +229,7 @@ TALER_MERCHANT_post_order_refund (struct GNUNET_CURL_Context *ctx,
req))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req);
GNUNET_free (orh->url);
GNUNET_free (orh);
diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c
index 2cd16cba..8cd9cbdd 100644
--- a/src/lib/merchant_api_post_orders.c
+++ b/src/lib/merchant_api_post_orders.c
@@ -329,11 +329,13 @@ TALER_MERCHANT_orders_post2 (
}
eh = curl_easy_init ();
GNUNET_assert (NULL != eh);
- if (GNUNET_OK != TALER_curl_easy_post (&po->post_ctx,
- eh,
- req))
+ if (GNUNET_OK !=
+ TALER_curl_easy_post (&po->post_ctx,
+ eh,
+ req))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req);
GNUNET_free (po);
return NULL;
diff --git a/src/lib/merchant_api_post_reserves.c b/src/lib/merchant_api_post_reserves.c
index 6957d480..2f970d60 100644
--- a/src/lib/merchant_api_post_reserves.c
+++ b/src/lib/merchant_api_post_reserves.c
@@ -206,11 +206,13 @@ TALER_MERCHANT_reserves_post (
exchange_url));
eh = curl_easy_init ();
GNUNET_assert (NULL != eh);
- if (GNUNET_OK != TALER_curl_easy_post (&prh->post_ctx,
- eh,
- req))
+ if (GNUNET_OK !=
+ TALER_curl_easy_post (&prh->post_ctx,
+ eh,
+ req))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req);
GNUNET_free (prh);
return NULL;
diff --git a/src/lib/merchant_api_post_transfers.c b/src/lib/merchant_api_post_transfers.c
index 62984835..488b0a7c 100644
--- a/src/lib/merchant_api_post_transfers.c
+++ b/src/lib/merchant_api_post_transfers.c
@@ -311,11 +311,13 @@ TALER_MERCHANT_transfers_post (
exchange_url));
eh = curl_easy_init ();
GNUNET_assert (NULL != eh);
- if (GNUNET_OK != TALER_curl_easy_post (&pth->post_ctx,
- eh,
- req))
+ if (GNUNET_OK !=
+ TALER_curl_easy_post (&pth->post_ctx,
+ eh,
+ req))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (req);
GNUNET_free (pth);
return NULL;
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index 0a9c3d86..d4a686f8 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -271,6 +271,7 @@ TALER_MERCHANT_tip_authorize2 (
te_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (te_obj);
GNUNET_free (tao->url);
GNUNET_free (tao);
@@ -331,11 +332,13 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
next_url));
eh = curl_easy_init ();
GNUNET_assert (NULL != eh);
- if (GNUNET_OK != TALER_curl_easy_post (&tao->post_ctx,
- eh,
- te_obj))
+ if (GNUNET_OK !=
+ TALER_curl_easy_post (&tao->post_ctx,
+ eh,
+ te_obj))
{
GNUNET_break (0);
+ curl_easy_cleanup (eh);
json_decref (te_obj);
GNUNET_free (tao->url);
GNUNET_free (tao);
diff --git a/src/lib/merchant_api_wallet_post_order_refund.c b/src/lib/merchant_api_wallet_post_order_refund.c
index 1ba8b33c..c09874ed 100644
--- a/src/lib/merchant_api_wallet_post_order_refund.c
+++ b/src/lib/merchant_api_wallet_post_order_refund.c
@@ -390,6 +390,7 @@ TALER_MERCHANT_wallet_post_order_refund (
{
GNUNET_break (0);
json_decref (req);
+ curl_easy_cleanup (eh);
GNUNET_free (orh->url);
GNUNET_free (orh);
return NULL;
diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c
index 1568d151..81b79091 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -415,7 +415,6 @@ orders_run2 (void *cls,
{
struct OrdersState *ps = cls;
const json_t *order;
- json_error_t error;
char *products_string = GNUNET_strdup (ps->products);
char *locks_string = GNUNET_strdup (ps->locks);
char *token;
@@ -454,21 +453,20 @@ orders_run2 (void *cls,
// FIXME: should probably use get_monotone() to ensure uniqueness!
now = GNUNET_TIME_absolute_get ();
- order_id = GNUNET_STRINGS_data_to_string_alloc
- (&now.abs_value_us,
- sizeof (now.abs_value_us));
- json_object_set_new (ps->order_terms,
- "order_id",
- json_string (order_id));
+ order_id = GNUNET_STRINGS_data_to_string_alloc (
+ &now.abs_value_us,
+ sizeof (now.abs_value_us));
+ GNUNET_assert (0 ==
+ json_object_set_new (ps->order_terms,
+ "order_id",
+ json_string (order_id)));
GNUNET_free (order_id);
}
order = ps->order_terms;
}
if (NULL == order)
{
- // human error here.
GNUNET_break (0);
- fprintf (stderr, "%s\n", error.text);
TALER_TESTING_interpreter_fail (is);
return;
}