Fix a segfault in the pkeyutl command line app

Don't attempt to deref a pkey that is NULL

Fixes #27156

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27228)
This commit is contained in:
Matt Caswell 2025-04-01 10:31:33 +01:00 committed by Tomas Mraz
parent db9771b5a0
commit 3f0f723b52
1 changed files with 4 additions and 0 deletions

View File

@ -318,6 +318,10 @@ int pkeyutl_main(int argc, char **argv)
} }
pkey = get_pkey(kdfalg, inkey, keyform, key_type, passinarg, pkey_op, e); pkey = get_pkey(kdfalg, inkey, keyform, key_type, passinarg, pkey_op, e);
if (key_type != KEY_NONE && pkey == NULL) {
BIO_printf(bio_err, "%s: Error loading key\n", prog);
goto end;
}
if (pkey_op == EVP_PKEY_OP_VERIFYRECOVER && !EVP_PKEY_is_a(pkey, "RSA")) { if (pkey_op == EVP_PKEY_OP_VERIFYRECOVER && !EVP_PKEY_is_a(pkey, "RSA")) {
BIO_printf(bio_err, "%s: -verifyrecover can be used only with RSA\n", prog); BIO_printf(bio_err, "%s: -verifyrecover can be used only with RSA\n", prog);