libpq leaks memory for SSL connections - Mailing list pgsql-bugs

From Timo Sirainen
Subject libpq leaks memory for SSL connections
Date
Msg-id CE981CB2-8907-4530-9886-24A54C9056B9@sirainen.com
Whole thread Raw
Responses Re: libpq leaks memory for SSL connections  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I noticed with valgrind how libpq is leaking memory:

at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x5F645C8: CRYPTO_zalloc (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
by 0x5E94EEF: BIO_meth_new (in /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1)
by 0x65181EB: ??? (in /usr/lib/x86_64-linux-gnu/libpq.so.5.11)
by 0x651950C: ??? (in /usr/lib/x86_64-linux-gnu/libpq.so.5.11)
by 0x650140F: PQconnectPoll (in /usr/lib/x86_64-linux-gnu/libpq.so.5.11)

Debian doesn't have debuginfo packages for libpq, but looking at the code I think it's pretty clear where the bug is:

my_SSL_set_fd() calls my_BIO_s_socket() which allocates memory with BIO_meth_new(), but nothing ever frees it. Note
thatOpenSSL's BIO_s_socket() returns a const pointer to statically allocated memory. 




pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17209: The latest pgdg-redhat-repo-latest.noarch has incorrect path for pgdg14
Next
From: PG Bug reporting form
Date:
Subject: BUG #17210: Postgres Let'sEncrypt root certificate is expired and breaks installation of postgres-client