Possible memory leak in pgcrypto with EVP_MD_CTX

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Possible memory leak in pgcrypto with EVP_MD_CTX
Дата
Msg-id 20201015072212.GC2305@paquier.xyz
обсуждение исходный текст
Ответы Re: Possible memory leak in pgcrypto with EVP_MD_CTX  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
Hi all,

It happens that pgcrypto has the following leak if a digest cannot be
initialized:
--- a/contrib/pgcrypto/openssl.c
+++ b/contrib/pgcrypto/openssl.c
@@ -202,6 +202,7 @@ px_find_digest(const char *name, PX_MD **res)
    }
    if (EVP_DigestInit_ex(ctx, md, NULL) == 0)
    {
+       EVP_MD_CTX_destroy(ctx);
        pfree(digest);
        return -1;
    }

That's a bit annoying, because this memory is allocated directly by
OpenSSL, and Postgres does not know how to free it until it gets
registered in the list of open_digests that would be used by the
cleanup callback, so I think that we had better back-patch this fix.

Thoughts?
--
Michael

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: Add Information during standby recovery conflicts
Следующее
От: Dilip Kumar
Дата:
Сообщение: Re: Logical replication CPU-bound with TRUNCATE/DROP/CREATE many tables