commit a43df1b23aa7843ab7770176328c9d5881d667c0
parent 7be09dcc18d9b1dff53db38c6da71d3a68349fc8
Author: Bohdan Potuzhnyi <potub1@bfh.ch>
Date: Sun, 15 Sep 2024 10:58:54 +0000
update of the check for gcry_md_open
Diffstat:
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/challenger/challenger-httpd_token.c b/src/challenger/challenger-httpd_token.c
@@ -429,12 +429,22 @@ CH_handler_token (struct CH_HandlerContext *hc,
char *encoded_hash = NULL;
size_t encoded_len;
- // Initialize libgcrypt
- if (!gcry_check_version(GCRYPT_VERSION)) {
- fprintf(stderr, "libgcrypt version mismatch\n");
- exit(2);
- }
- gcry_md_open(&hd, GCRY_MD_SHA256, 0);
+ if(GPG_ERR_NO_ERROR != gcry_md_open(&hd, GCRY_MD_SHA256, 0))
+ {
+ GNUNET_break_op(0);
+ GNUNET_free(client_scope);
+ GNUNET_free(client_secret);
+ GNUNET_free(client_redirect_uri);
+ GNUNET_free(client_state);
+ GNUNET_free(code_challenge);
+ GNUNET_free(code_challenge_method);
+ return TALER_MHD_reply_with_oauth_error(
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ "server_error",
+ TALER_EC_CHALLENGER_HELPER_EXEC_FAILED,
+ "Failed to initialize SHA256 hash function");
+ }
gcry_md_write(hd, bc->code_verifier, strlen(bc->code_verifier));
memcpy(hash, gcry_md_read(hd, 0), 32);
gcry_md_close(hd);