aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-19 13:35:43 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-19 13:35:43 +0100
commit807d8bc287cd1004b1726a43cc71f8d8dd7e9cdd (patch)
treed098068d00ff686f18ad707ae58e91bcd98b5a14
parent0be78bafee2d7e1c6df48ec78f6ba1bcf17b1295 (diff)
-fix more leaks
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c2
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c2
-rw-r--r--src/backend/taler-merchant-httpd_post-using-templates.c209
-rw-r--r--src/backend/taler-merchant-httpd_private-post-instances.c31
-rw-r--r--src/testing/testing_api_cmd_checkserver.c19
5 files changed, 146 insertions, 117 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index c1db5ea9..f97d9d40 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -252,8 +252,10 @@ resume_by_event (void *cls,
{
GNUNET_break (0);
GNUNET_async_scope_restore (&old);
+ GNUNET_free (as);
return;
}
+ GNUNET_free (as);
if (GNUNET_OK !=
TALER_amount_cmp_currency (&god->sc.refund_expected,
&a))
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 957bfdfa..61f232aa 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -2353,7 +2353,7 @@ parse_pay (struct PayContext *pc)
{
if (0 ==
strcmp (pc->egs[i]->exchange_url,
- GNUNET_strdup (exchange_url)))
+ exchange_url))
{
have_eg = true;
break;
diff --git a/src/backend/taler-merchant-httpd_post-using-templates.c b/src/backend/taler-merchant-httpd_post-using-templates.c
index 9252afc8..0f875853 100644
--- a/src/backend/taler-merchant-httpd_post-using-templates.c
+++ b/src/backend/taler-merchant-httpd_post-using-templates.c
@@ -112,124 +112,133 @@ TMH_post_using_templates_ID (const struct TMH_RequestHandler *rh,
} /* End of the switch */
}
- const char *tsummary;
- uint32_t min_age;
- struct GNUNET_TIME_Relative pay_duration;
- struct TALER_Amount tamount;
- bool no_tamount;
-
- struct GNUNET_JSON_Specification tspec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("summary",
- &tsummary),
- NULL),
- GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &tamount),
- &no_tamount),
- GNUNET_JSON_spec_uint32 ("minimum_age",
- &min_age),
- GNUNET_JSON_spec_relative_time ("pay_duration",
- &pay_duration),
- GNUNET_JSON_spec_end ()
- };
-
{
- enum GNUNET_GenericReturnValue res;
- const char *err_name;
- unsigned int err_line;
+ const char *tsummary;
+ uint32_t min_age;
+ struct GNUNET_TIME_Relative pay_duration;
+ struct TALER_Amount tamount;
+ bool no_tamount;
+
+ struct GNUNET_JSON_Specification tspec[] = {
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("summary",
+ &tsummary),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_amount ("amount",
+ TMH_currency,
+ &tamount),
+ &no_tamount),
+ GNUNET_JSON_spec_uint32 ("minimum_age",
+ &min_age),
+ GNUNET_JSON_spec_relative_time ("pay_duration",
+ &pay_duration),
+ GNUNET_JSON_spec_end ()
+ };
- res = GNUNET_JSON_parse (etp.template_contract,
- tspec,
- &err_name,
- &err_line);
- if (GNUNET_OK != res)
{
- GNUNET_break (0);
- json_dumpf (etp.template_contract,
- stderr,
- JSON_INDENT (2));
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- err_name);
+ enum GNUNET_GenericReturnValue res;
+ const char *err_name;
+ unsigned int err_line;
+
+ res = GNUNET_JSON_parse (etp.template_contract,
+ tspec,
+ &err_name,
+ &err_line);
+ if (GNUNET_OK != res)
+ {
+ GNUNET_break (0);
+ json_dumpf (etp.template_contract,
+ stderr,
+ JSON_INDENT (2));
+ TALER_MERCHANTDB_template_details_free (&etp);
+ GNUNET_JSON_parse_free (spec);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ err_name);
+ }
}
- }
-
- // if amount given in template AND request
- if ((! no_amount) && (! no_tamount))
- {
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT,
- NULL);
- }
- // if there is no amount in template and request
- if (no_amount && no_tamount)
- {
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT,
- NULL);
- }
+ if ( (! no_amount) &&
+ (! no_tamount) )
+ {
+ GNUNET_JSON_parse_free (spec);
+ TALER_MERCHANTDB_template_details_free (&etp);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT,
+ NULL);
+ }
- if ( (NULL!=summary) && (NULL != tsummary))
- {
+ if (no_amount && no_tamount)
+ {
+ GNUNET_JSON_parse_free (spec);
+ TALER_MERCHANTDB_template_details_free (&etp);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT,
+ NULL);
+ }
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT,
- NULL);
- }
+ if ( (NULL != summary) &&
+ (NULL != tsummary) )
+ {
+ GNUNET_JSON_parse_free (spec);
+ TALER_MERCHANTDB_template_details_free (&etp);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT,
+ NULL);
+ }
- // if there is no summary in template and request
- if ( (NULL == summary) && (NULL == tsummary) )
- {
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY,
- NULL);
+ if ( (NULL == summary) &&
+ (NULL == tsummary) )
+ {
+ GNUNET_JSON_parse_free (spec);
+ TALER_MERCHANTDB_template_details_free (&etp);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY,
+ NULL);
+ }
+ no_summary = (NULL == summary);
+ fake_body = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_object_steal ("order",
+ GNUNET_JSON_PACK (
+ TALER_JSON_pack_amount ("amount",
+ no_amount ?
+ &tamount :
+ &amount),
+ GNUNET_JSON_pack_string ("summary",
+ no_summary ?
+ tsummary :
+ summary),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string (
+ "fulfillment_url",
+ fulfillment_url)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string (
+ "fulfillment_message",
+ fulfillment_message))
+ ))
+ );
}
- no_summary = (NULL == summary);
- fake_body = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_object_steal ("order",
- GNUNET_JSON_PACK (
- TALER_JSON_pack_amount ("amount",
- no_amount ?
- &tamount :
- &amount),
- GNUNET_JSON_pack_string ("summary",
- no_summary ?
- tsummary :
- summary),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string (
- "fulfillment_url",
- fulfillment_url)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string (
- "fulfillment_message",
- fulfillment_message))
- ))
- );
- TALER_MERCHANTDB_template_details_free (&etp);
{
struct TMH_HandlerContext fake_hc = {
.request_body = fake_body,
.instance = hc->instance
};
- mret = TMH_private_post_orders (NULL, /* not even used */
+ mret = TMH_private_post_orders (NULL, /* not even used */
connection,
&fake_hc);
}
+ TALER_MERCHANTDB_template_details_free (&etp);
json_decref (fake_body);
return mret;
}
diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c
index 58a93b27..89bd937e 100644
--- a/src/backend/taler-merchant-httpd_private-post-instances.c
+++ b/src/backend/taler-merchant-httpd_private-post-instances.c
@@ -159,15 +159,15 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh,
(const char **) &is.id),
GNUNET_JSON_spec_string ("name",
(const char **) &is.name),
- GNUNET_JSON_spec_mark_optional(
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("email",
(const char **) &is.email),
NULL),
- GNUNET_JSON_spec_mark_optional(
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("website",
(const char **) &is.website),
NULL),
- GNUNET_JSON_spec_mark_optional(
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("logo",
(const char **) &is.logo),
NULL),
@@ -229,6 +229,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh,
if (! once)
{
+ once = true;
GNUNET_assert (0 ==
regcomp (&reg,
"^[A-Za-z0-9][A-Za-z0-9_.@-]+$",
@@ -297,18 +298,18 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh,
is.id)) &&
(0 == strcmp (mi->settings.name,
is.name)) &&
- ((mi->settings.email == is.email) ||
- (NULL != is.email && NULL != mi->settings.email &&
- 0 == strcmp (mi->settings.email,
- is.email))) &&
- ((mi->settings.website == is.website) ||
- (NULL != is.website && NULL != mi->settings.website &&
- 0 == strcmp (mi->settings.website,
- is.website))) &&
- ((mi->settings.logo == is.logo) ||
- (NULL != is.logo && NULL != mi->settings.logo &&
- 0 == strcmp (mi->settings.logo,
- is.logo))) &&
+ ((mi->settings.email == is.email) ||
+ (NULL != is.email && NULL != mi->settings.email &&
+ 0 == strcmp (mi->settings.email,
+ is.email))) &&
+ ((mi->settings.website == is.website) ||
+ (NULL != is.website && NULL != mi->settings.website &&
+ 0 == strcmp (mi->settings.website,
+ is.website))) &&
+ ((mi->settings.logo == is.logo) ||
+ (NULL != is.logo && NULL != mi->settings.logo &&
+ 0 == strcmp (mi->settings.logo,
+ is.logo))) &&
( ( (NULL != auth_token) &&
(GNUNET_OK ==
TMH_check_auth (auth_token,
diff --git a/src/testing/testing_api_cmd_checkserver.c b/src/testing/testing_api_cmd_checkserver.c
index 56b05438..aa75e374 100644
--- a/src/testing/testing_api_cmd_checkserver.c
+++ b/src/testing/testing_api_cmd_checkserver.c
@@ -202,6 +202,22 @@ checkserver_run (void *cls,
}
+/**
+ * Free the state of a "checkeserver" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command being run.
+ */
+static void
+checkserver_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ struct CheckState *cs = cls;
+
+ GNUNET_free (cs);
+}
+
+
struct TALER_TESTING_Command
TALER_TESTING_cmd_checkserver2 (const char *label,
const char *ref_operation,
@@ -225,7 +241,8 @@ TALER_TESTING_cmd_checkserver2 (const char *label,
struct TALER_TESTING_Command cmd = {
.cls = cs,
.label = label,
- .run = &checkserver_run
+ .run = &checkserver_run,
+ .cleanup = &checkserver_cleanup
};
return cmd;