merchant

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

commit 279866ee19cc8af9e09efe0d24cd6040291dbd2c
parent cc81e77cd7f4d5e8b93d2af3eb63f392635d8845
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 30 Aug 2025 23:55:14 +0200

-fix memory leak

Diffstat:
Msrc/backend/taler-merchant-httpd.h | 10+++++++---
Msrc/backend/taler-merchant-httpd_private-post-instances-ID-token.c | 20+++++++++++++-------
2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h @@ -898,7 +898,9 @@ TMH_compute_auth (const char *password, * @return true if it was a subset, false otherwise. */ bool -TMH_scope_is_subset (enum TMH_AuthScope as, enum TMH_AuthScope candidate); +TMH_scope_is_subset (enum TMH_AuthScope as, + enum TMH_AuthScope candidate); + /** * Return the TMH_AuthScope corresponding to @a name. @@ -909,6 +911,7 @@ TMH_scope_is_subset (enum TMH_AuthScope as, enum TMH_AuthScope candidate); enum TMH_AuthScope TMH_get_scope_by_name (const char *name); + /** * Return the name corresponding to @a scop. * @@ -916,7 +919,8 @@ TMH_get_scope_by_name (const char *name); * @param[out] refreshable outputs if scope value was refreshable * @return the name corresponding to the scope, or NULL. */ -const char* -TMH_get_name_by_scope (enum TMH_AuthScope scope, bool *refreshable); +const char * +TMH_get_name_by_scope (enum TMH_AuthScope scope, + bool *refreshable); #endif diff --git a/src/backend/taler-merchant-httpd_private-post-instances-ID-token.c b/src/backend/taler-merchant-httpd_private-post-instances-ID-token.c @@ -33,6 +33,7 @@ */ #define DEFAULT_DURATION GNUNET_TIME_UNIT_DAYS + MHD_RESULT TMH_private_post_instances_ID_token (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, @@ -42,7 +43,7 @@ TMH_private_post_instances_ID_token (const struct TMH_RequestHandler *rh, json_t *jtoken = hc->request_body; const char *scope; const char *description; - uint32_t iscope = TMH_AS_NONE; + enum TMH_AuthScope iscope = TMH_AS_NONE; bool refreshable = false; struct TALER_MERCHANTDB_LoginTokenP btoken; struct GNUNET_TIME_Relative duration @@ -84,13 +85,16 @@ TMH_private_post_instances_ID_token (const struct TMH_RequestHandler *rh, char *tmp_scope; char *scope_prefix; char *scope_suffix; - tmp_scope = GNUNET_strdup (scope); - scope_prefix = strtok (tmp_scope, ":"); - scope_suffix = strtok (NULL, ":"); + tmp_scope = GNUNET_strdup (scope); + scope_prefix = strtok (tmp_scope, + ":"); + scope_suffix = strtok (NULL, + ":"); /* We allow <SCOPE>:REFRESHABLE syntax */ - if ((NULL != scope_suffix) && - (0 == strcasecmp (scope_suffix, "refreshable"))) + if ( (NULL != scope_suffix) && + (0 == strcasecmp (scope_suffix, + "refreshable"))) refreshable = true; iscope = TMH_get_scope_by_name (scope_prefix); if (TMH_AS_NONE == iscope) @@ -101,10 +105,12 @@ TMH_private_post_instances_ID_token (const struct TMH_RequestHandler *rh, TALER_EC_GENERIC_PARAMETER_MALFORMED, "scope"); } + GNUNET_free (tmp_scope); } if (refreshable) iscope |= TMH_AS_REFRESHABLE; - if (! TMH_scope_is_subset (hc->auth_scope, iscope)) + if (! TMH_scope_is_subset (hc->auth_scope, + iscope)) { /* more permissions requested for the new token, not allowed */ GNUNET_break_op (0);