postgres.git / summary / log / commit / refs

commit    e835e89a0fd267871e7fbddc39ad00ee3d0cb55c
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sat Mar 20 16:47:21 2021 +0000
First released in: 14.0, 10.17, 11.12, 12.7, 13.3

    Fix memory leak when rejecting bogus DH parameters.
    
    While back-patching e0e569e1d, I noted that there were some other
    places where we ought to be applying DH_free(); namely, where we
    load some DH parameters from a file and then reject them as not
    being sufficiently secure.  While it seems really unlikely that
    anybody would hit these code paths in production, let alone do
    so repeatedly, let's fix it for consistency.
    
    Back-patch to v10 where this code was introduced.
    
    Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org


src/backend/libpq/be-secure-openssl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index ad33122e0ed..5ce3f27855e 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -922,6 +922,7 @@ load_dh_file(char *filename, bool isServerStart) (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("invalid DH parameters: %s", SSLerrmessage(ERR_get_error())))); + DH_free(dh); return NULL; } if (codes & DH_CHECK_P_NOT_PRIME) @@ -929,6 +930,7 @@ load_dh_file(char *filename, bool isServerStart) ereport(isServerStart ? FATAL : LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("invalid DH parameters: p is not prime"))); + DH_free(dh); return NULL; } if ((codes & DH_NOT_SUITABLE_GENERATOR) && @@ -937,6 +939,7 @@ load_dh_file(char *filename, bool isServerStart) ereport(isServerStart ? FATAL : LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("invalid DH parameters: neither suitable generator or safe prime"))); + DH_free(dh); return NULL; } [parent: f0c2a5bba6c5]