pem: avoid segfault if PKEY is NULL in PEM_write_bio_PrivateKey
authorMilan Broz <gmazyland@gmail.com>
Sat, 29 Oct 2022 09:48:51 +0000 (11:48 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 10 Nov 2022 17:10:48 +0000 (18:10 +0100)
commit373d90128042cb0409e347827d80b50a99d3965a
tree64b4a300cee9a2bee10a2792e823a339d08ec6e7
parent608aca8ed2becccfe9c238846834ea2b162fc98b
pem: avoid segfault if PKEY is NULL in PEM_write_bio_PrivateKey

Make the code more robust and correctly handle EVP_PKEY set to NULL
instead of dereferencing null pointer.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19536)
crypto/pem/pem_pkey.c
test/evp_pkey_provided_test.c