[openssl/openssl] 60d391: pem: fix a memory leak in PEM_write_bio_PrivateKey...

Milan Broz noreply at github.com
Thu Nov 10 17:14:04 UTC 2022


  Branch: refs/heads/openssl-3.0
  Home:   https://github.com/openssl/openssl
  Commit: 60d391b6f0178e1f1afac242db460a14590bc03e
      https://github.com/openssl/openssl/commit/60d391b6f0178e1f1afac242db460a14590bc03e
  Author: Milan Broz <gmazyland at gmail.com>
  Date:   2022-11-10 (Thu, 10 Nov 2022)

  Changed paths:
    M crypto/pem/pem_pkey.c

  Log Message:
  -----------
  pem: fix a memory leak in PEM_write_bio_PrivateKey_traditional

The copy of PKEY should be released on the error path.
Easily reproduced with "ED448" context.

Signed-off-by: Milan Broz <gmazyland at gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit at gmail.com>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19536)

(cherry picked from commit 608aca8ed2becccfe9c238846834ea2b162fc98b)


  Commit: 2fee530c86d5e203a311e0857330fa94ab18c6e9
      https://github.com/openssl/openssl/commit/2fee530c86d5e203a311e0857330fa94ab18c6e9
  Author: Milan Broz <gmazyland at gmail.com>
  Date:   2022-11-10 (Thu, 10 Nov 2022)

  Changed paths:
    M crypto/pem/pem_pkey.c
    M test/evp_pkey_provided_test.c

  Log Message:
  -----------
  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 at gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit at gmail.com>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19536)

(cherry picked from commit 373d90128042cb0409e347827d80b50a99d3965a)


Compare: https://github.com/openssl/openssl/compare/b8a5adf3ec46...2fee530c86d5


More information about the openssl-commits mailing list