From: Paul Eggert Date: Sun, 22 Feb 2026 17:58:37 +0000 (-0800) Subject: crypto/sha3: fix errno when freeing X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a171eea4c8595347b43390a5328afb726fbed6da;p=thirdparty%2Fgnulib.git crypto/sha3: fix errno when freeing * lib/sha3.c (sha3_free_ctx): Preserve errno. * modules/crypto/sha3 (Depends-on): * modules/crypto/sha3-buffer (Depends-on): Depend on free-posix. --- diff --git a/ChangeLog b/ChangeLog index 47606778bc..cabca53248 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2026-02-22 Paul Eggert + crypto/sha3: fix errno when freeing + * lib/sha3.c (sha3_free_ctx): Preserve errno. + * modules/crypto/sha3 (Depends-on): + * modules/crypto/sha3-buffer (Depends-on): + Depend on free-posix. + crypto/sha3: fix memory leak with OpenSSL wrapper * lib/sha3.c (sha3_##SIZE##_buffer): Free ctx before returning. diff --git a/lib/sha3.c b/lib/sha3.c index f7ca3c4abb..2a97190e07 100644 --- a/lib/sha3.c +++ b/lib/sha3.c @@ -364,8 +364,10 @@ sha3_free_ctx (struct sha3_ctx *ctx) { if (ctx->evp_ctx != NULL) { + int saved_errno = errno; EVP_MD_CTX_free (ctx->evp_ctx); ctx->evp_ctx = NULL; + errno = saved_errno; } } diff --git a/modules/crypto/sha3 b/modules/crypto/sha3 index f2b878794a..50e2ead34f 100644 --- a/modules/crypto/sha3 +++ b/modules/crypto/sha3 @@ -7,6 +7,7 @@ lib/sha3-stream.c Depends-on: crypto/af_alg crypto/sha3-buffer +free-posix configure.ac: diff --git a/modules/crypto/sha3-buffer b/modules/crypto/sha3-buffer index 7ab61dea30..00c2f230a4 100644 --- a/modules/crypto/sha3-buffer +++ b/modules/crypto/sha3-buffer @@ -11,6 +11,7 @@ Depends-on: bool byteswap c99 +free-posix stddef-h stdint-h u64