]> git.ipfire.org Git - thirdparty/openssl.git/commit
crypto/evp/m_sigver.c: fix potential double free on error path in do_sigver_init
authoryangxuqing <43904538+RigelYoung@users.noreply.github.com>
Sat, 23 May 2026 02:33:35 +0000 (10:33 +0800)
committerEugene Syromiatnikov <esyr@openssl.org>
Tue, 26 May 2026 15:27:02 +0000 (17:27 +0200)
commitecb4757b377ffb468b39bee76ed6d38f6bf51416
tree939586d7892ed57fa516fad89f58900423b3f3e6
parentd73ad5615c40ea80c70ffd5496c407d77325ab05
crypto/evp/m_sigver.c: fix potential double free on error path in do_sigver_init

In do_sigver_init(), if the for loop proceeds to its second iteration
(iter = 2), the results from the first iteration (signature and
tmp_keymgmt) are explicitly freed at the beginning of the loop.
However, the pointers are not set to NULL after being freed.

If an error occurs subsequently during this second iteration (for
example, if evp_signature_fetch_from_prov() returns NULL, triggering a
goto notsupported), the control flow jumps to the generic cleanup block
at the end of the function. This cleanup block calls
EVP_KEYMGMT_free(tmp_keymgmt) again on the dangling pointer, resulting
in a double free.

This commit resolves the issue by explicitly nullifying these pointers
immediately after they are freed at the start of the loop iteration.

(Note: This issue was discussed with the OpenSSL Security Team, who
classified it as a regular bug due to lack of attacker control and
requested a public PR.)

Fixes: 839ffdd11cd4 "EVP: Allow a fallback for operations that work with an EVP_PKEY"
CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Tue May 26 15:28:15 2026
(Merged from https://github.com/openssl/openssl/pull/31276)
crypto/evp/m_sigver.c