Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 992cba9

Browse files
committed
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 e0e569e. 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 c0a15e0, and didn't have a leak in the actually-live code paths. Michael Paquier Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org
1 parent 4eca51d commit 992cba9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/libpq/be-secure-openssl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,11 @@ initialize_dh(SSL_CTX *context, bool isServerStart)
10291029
(errcode(ERRCODE_CONFIG_FILE_ERROR),
10301030
(errmsg("DH: could not set DH parameters: %s",
10311031
SSLerrmessage(ERR_get_error())))));
1032+
DH_free(dh);
10321033
return false;
10331034
}
1035+
1036+
DH_free(dh);
10341037
return true;
10351038
}
10361039

0 commit comments

Comments
 (0)