commit e2c1e271522f8b446d477396fae7b0922d003b46
parent 60024bbd1180e938c44a10753d53d79a6b6affd0
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sun, 19 Jul 2026 15:57:04 +0200
cleaner drop-if-exists
Diffstat:
4 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/src/challenger/challenger-admin.c b/src/challenger/challenger-admin.c
@@ -154,7 +154,7 @@ run (void *cls,
"CLIENT_SECRET must begin with `%s'\n",
RFC_8959_PREFIX);
global_ret = EXIT_INVALIDARGUMENT;
- return;
+ goto cleanup;
}
if (NULL != client_id)
{
diff --git a/src/challenger/challenger-httpd_common.c b/src/challenger/challenger-httpd_common.c
@@ -64,18 +64,20 @@ CH_get_client_secret (struct MHD_Connection *connection)
if (NULL == auth)
return NULL;
/* RFC 7235: the auth-scheme token ("Bearer") is case-insensitive. */
- if (0 != strncasecmp (auth,
- bearer,
- strlen (bearer)))
+ if (0 !=
+ strncasecmp (auth,
+ bearer,
+ strlen (bearer)))
{
return NULL;
}
tok = auth + strlen (bearer);
while (' ' == *tok)
tok++;
- if (0 != strncasecmp (tok,
- RFC_8959_PREFIX,
- strlen (RFC_8959_PREFIX)))
+ if (0 !=
+ strncasecmp (tok,
+ RFC_8959_PREFIX,
+ strlen (RFC_8959_PREFIX)))
{
return NULL;
}
@@ -98,6 +100,7 @@ CH_compute_code (const struct CHALLENGER_ValidationNonceP *nonce,
astr = json_dumps (address,
JSON_COMPACT);
+ GNUNET_assert (NULL != astr);
GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_hkdf_gnunet (
&h,
diff --git a/src/challenger/challenger-httpd_setup.c b/src/challenger/challenger-httpd_setup.c
@@ -175,6 +175,9 @@ CH_handler_setup (struct CH_HandlerContext *hc,
"read_only");
}
}
+ /* FIXME: the two transactions below should be folded
+ into a single transaction (both to only increment
+ the validation counter on success and for performance). */
for (unsigned int r = 0; r<MAX_RETRIES; r++)
{
enum GNUNET_DB_QueryStatus qs;
@@ -189,23 +192,26 @@ CH_handler_setup (struct CH_HandlerContext *hc,
{
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
- return TALER_MHD_reply_with_error (hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- NULL);
+ return TALER_MHD_reply_with_error (
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "client_check");
case GNUNET_DB_STATUS_SOFT_ERROR:
if (r < MAX_RETRIES - 1)
continue;
GNUNET_break (0);
- return TALER_MHD_reply_with_error (hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- NULL);
+ return TALER_MHD_reply_with_error (
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "client_check");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- return TALER_MHD_reply_with_error (hc->connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_CHALLENGER_GENERIC_CLIENT_UNKNOWN,
- NULL);
+ return TALER_MHD_reply_with_error (
+ hc->connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_CHALLENGER_GENERIC_CLIENT_UNKNOWN,
+ NULL);
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
@@ -231,16 +237,18 @@ CH_handler_setup (struct CH_HandlerContext *hc,
case GNUNET_DB_STATUS_HARD_ERROR:
case GNUNET_DB_STATUS_SOFT_ERROR:
GNUNET_break (0);
- return TALER_MHD_reply_with_error (hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "setup_nonce");
+ return TALER_MHD_reply_with_error (
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "setup_nonce");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0);
- return TALER_MHD_reply_with_error (hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- "no results from setup_nonce");
+ return TALER_MHD_reply_with_error (
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ "no results from setup_nonce");
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
diff --git a/src/challengerdb/challenger_do_validate_and_solve_pin.sql b/src/challengerdb/challenger_do_validate_and_solve_pin.sql
@@ -14,7 +14,8 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
-CREATE OR REPLACE FUNCTION challenger_do_validate_and_solve_pin (
+DROP FUNCTION IF EXISTS challenger_do_validate_and_solve_pin;
+CREATE FUNCTION challenger_do_validate_and_solve_pin (
IN in_nonce BYTEA,
IN in_new_pin INT4,
OUT out_not_found BOOLEAN,