aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-03-20 12:47:21 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-03-20 12:47:42 -0400
commit2f31414f4322876b34674eedc6e7d19c29ebe0d0 (patch)
treec6954b4f975f2d1a796218e3959015993dcc2e35 /src
parent992cba94d38ef20765e4c54e4dff00ae8a58a6c5 (diff)
downloadpostgresql-2f31414f4322876b34674eedc6e7d19c29ebe0d0.tar.gz
postgresql-2f31414f4322876b34674eedc6e7d19c29ebe0d0.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/libpq/be-secure-openssl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index 0374c49a47b..2536af8b3b8 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -850,6 +850,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)
@@ -857,6 +858,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) &&
@@ -865,6 +867,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;
}