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

Commit 4b41f69

Browse files
committed
Fix memory leak when rejecting bogus DH parameters.
While back-patching e0e569e, 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
1 parent 1235483 commit 4b41f69

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
@@ -899,13 +899,15 @@ load_dh_file(char *filename, bool isServerStart)
899899
(errcode(ERRCODE_CONFIG_FILE_ERROR),
900900
errmsg("invalid DH parameters: %s",
901901
SSLerrmessage(ERR_get_error()))));
902+
DH_free(dh);
902903
return NULL;
903904
}
904905
if (codes & DH_CHECK_P_NOT_PRIME)
905906
{
906907
ereport(isServerStart ? FATAL : LOG,
907908
(errcode(ERRCODE_CONFIG_FILE_ERROR),
908909
errmsg("invalid DH parameters: p is not prime")));
910+
DH_free(dh);
909911
return NULL;
910912
}
911913
if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
@@ -914,6 +916,7 @@ load_dh_file(char *filename, bool isServerStart)
914916
ereport(isServerStart ? FATAL : LOG,
915917
(errcode(ERRCODE_CONFIG_FILE_ERROR),
916918
errmsg("invalid DH parameters: neither suitable generator or safe prime")));
919+
DH_free(dh);
917920
return NULL;
918921
}
919922

0 commit comments

Comments
 (0)