From: Alex Rousskov Date: Mon, 12 Jul 2021 20:59:02 +0000 (+0000) Subject: Fix SslBump reconfiguration leaking public key memory (#861) X-Git-Tag: SQUID_6_0_1~312 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e70401d97328eb4c267d1013428109224d093e6;p=thirdparty%2Fsquid.git Fix SslBump reconfiguration leaking public key memory (#861) X509_get_pubkey() increments key reference count. Probably leaking since commit 2a268a0. --- diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc index fd437abc4b..36262e29ba 100644 --- a/src/ssl/gadgets.cc +++ b/src/ssl/gadgets.cc @@ -376,8 +376,10 @@ mimicExtensions(Security::CertPointer & cert, Security::CertPointer const &mimic DecipherOnly }; - EVP_PKEY *certKey = X509_get_pubkey(mimicCert.get()); - const bool rsaPkey = (EVP_PKEY_get0_RSA(certKey) != nullptr); + // XXX: Add PublicKeyPointer. In OpenSSL, public and private keys are + // internally represented by EVP_PKEY pair, but GnuTLS uses distinct types. + const Security::PrivateKeyPointer certKey(X509_get_pubkey(mimicCert.get())); + const auto rsaPkey = EVP_PKEY_get0_RSA(certKey.get()) != nullptr; int added = 0; int nid;