Commit 4972eeeb6a for openssl.org
commit 4972eeeb6aad64a6f362fd7b0b1e73e8e16e0ac8
Author: Greensi7 <adam.tabak04@gmail.com>
Date: Thu Aug 13 22:10:22 2026 +0200
Fix NULL dereference in try_key_value()
In store_result.c:try_key_value() return value of
OSSL_DECODER_CTX_new_for_pkey() is not checked so on
failed memory allocation OSSL_DECODER_CTX_set_passphrase_cb()
dereferences NULL without any check.
Found by : store fuzzer (MFAIL-test)
Reviewed-by: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Sep 15 14:20:04 2026
(Merged from https://github.com/openssl/openssl/pull/32413)
diff --git a/crypto/store/store_result.c b/crypto/store/store_result.c
index a47eb2a601..576e3d307e 100644
--- a/crypto/store/store_result.c
+++ b/crypto/store/store_result.c
@@ -308,6 +308,12 @@ static EVP_PKEY *try_key_value(struct extracted_param_data_st *data,
decoderctx = OSSL_DECODER_CTX_new_for_pkey(&pk, data->input_type, data->data_structure,
data->data_type, selection, libctx,
propq);
+
+ if (decoderctx == NULL) {
+ *harderr = 1;
+ return NULL;
+ }
+
(void)OSSL_DECODER_CTX_set_passphrase_cb(decoderctx, cb, cbarg);
/* No error if this couldn't be decoded */