commit 1783f8ebb8ad56ebe549a56374b56ea389f4533a
parent e85280ffc61f6aad93b4bd055254ebcf28f3eb05
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 21 Jun 2025 19:33:41 +0200
-minor code cleanup, fix strncmp() instance name comparison: must be strcmp()
Diffstat:
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -503,9 +503,15 @@ TMH_check_auth (const char *token,
}
+/**
+ * Check if @a token grants access to @a instance.
+ *
+ * @param token FIXME: clarify
+ * @param instances the access controlled instance
+ */
static enum GNUNET_GenericReturnValue
-TMH_check_auth_instance (const char *token,
- struct TMH_MerchantInstance *instance)
+check_auth_instance (const char *token,
+ struct TMH_MerchantInstance *instance)
{
char *tmp;
const char *instance_name;
@@ -540,13 +546,11 @@ TMH_check_auth_instance (const char *token,
GNUNET_free (tmp);
return GNUNET_SYSERR;
}
-
+ /* FIXME: how can instance->settings.id be NULL? */
if (NULL != instance->settings.id)
target_instance = instance->settings.id;
- // FIXME: why a *prefix* match and not a full-string match?
- if (0 != strncmp (instance_name,
- target_instance,
- strlen (target_instance)))
+ if (0 != strcmp (instance_name,
+ target_instance))
{
GNUNET_free (tmp);
return GNUNET_SYSERR;
@@ -924,10 +928,10 @@ extract_auth (const char **auth)
tok += offset;
while (' ' == *tok)
tok++;
- if ((GNUNET_YES == is_bearer) &&
- (0 != strncasecmp (tok,
- RFC_8959_PREFIX,
- strlen (RFC_8959_PREFIX))))
+ if ( (is_bearer) &&
+ (0 != strncasecmp (tok,
+ RFC_8959_PREFIX,
+ strlen (RFC_8959_PREFIX))) )
{
*auth = NULL;
return;
@@ -2194,11 +2198,9 @@ url_handler (void *cls,
bool is_basic_auth = false;
bool auth_malformed = false;
- /* PATCHing an instance can alternatively be checked against
- the default instance */
- auth = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_AUTHORIZATION);
+ auth = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_AUTHORIZATION);
if (NULL != auth)
{
@@ -2250,8 +2252,8 @@ url_handler (void *cls,
else
{
if (GNUNET_OK ==
- TMH_check_auth_instance (auth,
- hc->instance))
+ check_auth_instance (auth,
+ hc->instance))
hc->auth_scope = TMH_AS_ADMIN;
else
hc->auth_scope = TMH_AS_NONE;