libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit c082b1b9a88fb56b03c45dd88dc9d5120728bd3e
parent ddbab9dd6a873c14d62bf3cad5f7476763d414a3
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 23 Nov 2025 17:48:52 +0100

-fixes and cleanups to new hash logic

Diffstat:
Msrc/mhd2/md5_ext_gnutls.c | 17++++++++++++-----
Msrc/mhd2/md5_ext_openssl.c | 5++++-
Msrc/mhd2/sha256_ext_openssl.c | 3+++
3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/mhd2/md5_ext_gnutls.c b/src/mhd2/md5_ext_gnutls.c @@ -43,6 +43,7 @@ */ #include <gnutls/crypto.h> +#define MHD_MD5_Context struct hash_hd_st #include "md5_ext.h" #include "mhd_assert.h" @@ -65,8 +66,7 @@ mhd_MD5_init_one_time (struct mhd_Md5CtxExt *ctx) /* GnuTLS may return initialisation error and set the handle at the same time. Such handle cannot be used for calculations. Note: GnuTLS may also return an error and NOT set the handle. */ - gnutls_free (ctx->handle); - ctx->handle = NULL; + mhd_MD5_deinit (ctx); } /* If handle is NULL, the error must be set */ @@ -90,7 +90,9 @@ mhd_MD5_update (struct mhd_Md5CtxExt *ctx, { mhd_assert (0 != size); if (0 == ctx->ext_error) - ctx->ext_error = gnutls_hash (ctx->handle, data, size); + ctx->ext_error = gnutls_hash (ctx->handle, + data, + size); } @@ -105,7 +107,8 @@ mhd_MD5_finish_reset (struct mhd_Md5CtxExt *ctx, uint8_t digest[mhd_MD5_DIGEST_SIZE]) { if (0 == ctx->ext_error) - gnutls_hash_output (ctx->handle, digest); + gnutls_hash_output (ctx->handle, + digest); } @@ -118,5 +121,9 @@ void mhd_MD5_deinit (struct mhd_Md5CtxExt *ctx) { if (NULL != ctx->handle) - gnutls_hash_deinit (ctx->handle, NULL); + { + gnutls_hash_deinit (ctx->handle, + NULL); + ctx->handle = NULL; + } } diff --git a/src/mhd2/md5_ext_openssl.c b/src/mhd2/md5_ext_openssl.c @@ -43,7 +43,7 @@ */ #include <openssl/evp.h> -#define MHD_MD5_Context struct hash_hd_st +#define MHD_MD5_Context EVP_MD_CTX #include "md5_ext.h" #include "mhd_assert.h" @@ -130,7 +130,10 @@ mhd_MD5_finish_reset (struct mhd_Md5CtxExt *ctx, if (1 != EVP_DigestInit_ex (ctx->handle, EVP_md5 (), NULL)) + { ctx->ext_error = 1; + mhd_MD5_deinit (ctx); + } } diff --git a/src/mhd2/sha256_ext_openssl.c b/src/mhd2/sha256_ext_openssl.c @@ -131,7 +131,10 @@ mhd_SHA256_finish_reset (struct mhd_Sha256CtxExt *ctx, if (1 != EVP_DigestInit_ex (ctx->handle, EVP_sha256 (), NULL)) + { ctx->ext_error = 1; + mhd_SHA256_deinit (ctx); + } } }