challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit e7f9a8a938ef3aa7ae95b8fee26716832d56d98a
parent c8c570ffdeac73dfbe6b37fb924d826584e5e1c9
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sun, 19 Jul 2026 23:03:36 +0200

fix addr cmp in case addr is set via URL encoding where the read_only cannot be set to a boolean as all values must be encoded as strings

Diffstat:
Msrc/challenger/challenger-httpd_challenge.c | 40+++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/challenger/challenger-httpd_challenge.c b/src/challenger/challenger-httpd_challenge.c @@ -638,6 +638,35 @@ check_restrictions (const json_t *address) } +/** + * Check if @a a1 and @a a2 are equal, ignoring the + * "read_only" field. + * + * @param a1 addr to compare + * @param a2 addr to compare + * @return true if both are equal + */ +static bool +addr_equal (const json_t *a1, + const json_t *a2) +{ + bool ret; + json_t *j1 = json_deep_copy (a1); + json_t *j2 = json_deep_copy (a2); + + GNUNET_assert (NULL != j1); + GNUNET_assert (NULL != j2); + json_object_del (j1, + "read_only"); + json_object_del (j2, + "read_only"); + ret = (1 == json_equal (j1, j2)); + json_decref (j1); + json_decref (j2); + return ret; +} + + enum MHD_Result CH_handler_challenge (struct CH_HandlerContext *hc, const char *upload_data, @@ -828,7 +857,7 @@ CH_handler_challenge (struct CH_HandlerContext *hc, { enum GNUNET_DB_QueryStatus qs; json_t *old_address; - const json_t *ro; + json_t *ro; GNUNET_assert (NULL == bc->client_redirect_uri); qs = CHALLENGERDB_address_get (CH_context, @@ -863,8 +892,8 @@ CH_handler_challenge (struct CH_HandlerContext *hc, "read_only"); if ( (NULL != ro) && (json_boolean_value (ro)) && - (1 != json_equal (old_address, - bc->address)) ) + (! addr_equal (old_address, + bc->address)) ) { GNUNET_break_op (0); json_decref (old_address); @@ -874,6 +903,11 @@ CH_handler_challenge (struct CH_HandlerContext *hc, NULL); } json_decref (old_address); + if (ro) + GNUNET_assert (0 == + json_object_set (bc->address, + "read_only", + ro)); qs = CHALLENGERDB_challenge_set_address_and_pin (CH_context, &bc->nonce,