]> git.ipfire.org Git - thirdparty/gnulib.git/commit
crypto/sha3-buffer, crypto/sha3: Protect against double frees (regr. today).
authorCollin Funk <collin.funk1@gmail.com>
Sat, 6 Sep 2025 23:38:08 +0000 (16:38 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 6 Sep 2025 23:38:08 +0000 (16:38 -0700)
commita82f1b76386f8b446ef8aebf4c5089d8db0aa30e
tree25ac3f792201d1b85ed504b3720849bbbe639434
parentae13f814ee25b1701301b6c9e1c676eec7cc55a2
crypto/sha3-buffer, crypto/sha3: Protect against double frees (regr. today).

* lib/sha3.c (sha3_free_ctx): Only free the EVP_MD_CTX if it is not
NULL, and set it to NULL after freeing.
(DEFINE_SHA3_INIT_CTX, sha3_finish_ctx, sha3_process_bytes): Leave
freeing memory to the caller.
* lib/sha3-stream.c (sha3_xxx_stream): Call sha3_free_ctx on success and
if sha3_init_ctx fails.
* tests/test-sha3-224-buffer.c (main): Add a test that would otherwise
segfault without this patch.
* tests/test-sha3-256-buffer.c (main): Likewise.
* tests/test-sha3-384-buffer.c (main): Likewise.
* tests/test-sha3-512-buffer.c (main): Likewise.
ChangeLog
lib/sha3-stream.c
lib/sha3.c
lib/sha3.h
tests/test-sha3-224-buffer.c
tests/test-sha3-256-buffer.c
tests/test-sha3-384-buffer.c
tests/test-sha3-512-buffer.c