[openssl/openssl] 7c14ec: Fix internal memory leaks from OPENSSL_MALLOC_FAIL...

Bernd Edlinger noreply at github.com
Tue Sep 5 10:54:24 UTC 2023

  Branch: refs/heads/openssl-3.0
  Home:   https://github.com/openssl/openssl
  Commit: 7c14ec86fefeb3dc92e56e7937d10cbe60f13e67
  Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
  Date:   2023-09-05 (Tue, 05 Sep 2023)

  Changed paths:
    M crypto/mem.c

  Log Message:
  Fix internal memory leaks from OPENSSL_MALLOC_FAILURES

There is a rarely used feature that can be enabled
with `./config enable-crypto-mdebug` when additionally
the environment variable OPENSSL_MALLOC_FAILURES is used.
It turns out to be possible that CRYPTO_zalloc may
create a leak when the memory is allocated and then
the shouldfail happens, then the memory is lost.
Likewise when OPENSSL_realloc is used with size=0,
then the memory is to be free'd but here the shouldfail
check is too early, and the failure may prevent the
memory to be freed thus creating a bogus memory leak.

Reviewed-by: Matt Caswell <matt at openssl.org>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
Reviewed-by: Hugo Landau <hlandau at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21944)

(cherry picked from commit e2cf38d5751d6b48c8625b622c3765d0a39958d7)

More information about the openssl-commits mailing list