pgsql: Fix memory leak when initializing DH parameters in backend

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix memory leak when initializing DH parameters in backend
Date: 2021-03-20 16:48:06
Message-ID: E1lNeli-0004vc-W7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix memory leak when initializing DH parameters in backend

When loading DH parameters used for the generation of ephemeral DH keys
in the backend, the code has never bothered releasing the memory used
for the DH information loaded from a file or from libpq's default. This
commit makes sure that the information is properly free()'d.

Back-patch of e0e569e1d. We originally thought the leak was minor and
not worth back-patching, but Jelte Fennema pointed out that repeated
SIGHUP's can result in very serious bloat of the postmaster, which is
then multiplied by being duplicated into eadh forked child.

Back-patch to v10; the code looked different before c0a15e07c,
and didn't have a leak in the actually-live code paths.

Michael Paquier

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c49e287a8e4dbc3013a56f88793638f79a6ef099

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 3 +++
1 file changed, 3 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-03-20 16:48:07 pgsql: Fix memory leak when rejecting bogus DH parameters.
Previous Message Andrew Dunstan 2021-03-20 16:07:45 Re: pgsql: Blindly try to fix test script's tar invocation for MSYS.