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

Milan Broz noreply at github.com
Thu Nov 10 17:13:56 UTC 2022


  Branch: refs/heads/openssl-3.1
  Home:   https://github.com/openssl/openssl
  Commit: c8df0736e42b909a158282ffc7c04fec6acd18fe
      https://github.com/openssl/openssl/commit/c8df0736e42b909a158282ffc7c04fec6acd18fe
  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: 7abe06cbb52cf4c214f8eac1b5f9f3c6a38ed9fa
      https://github.com/openssl/openssl/commit/7abe06cbb52cf4c214f8eac1b5f9f3c6a38ed9fa
  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/80645dfb8fd6...7abe06cbb52c


More information about the openssl-commits mailing list