mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 12:17:26 +02:00
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
This commit is contained in:
parent
12354839e8
commit
4b41f69234
@ -899,6 +899,7 @@ load_dh_file(char *filename, bool isServerStart)
|
|||||||
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||||
errmsg("invalid DH parameters: %s",
|
errmsg("invalid DH parameters: %s",
|
||||||
SSLerrmessage(ERR_get_error()))));
|
SSLerrmessage(ERR_get_error()))));
|
||||||
|
DH_free(dh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (codes & DH_CHECK_P_NOT_PRIME)
|
if (codes & DH_CHECK_P_NOT_PRIME)
|
||||||
@ -906,6 +907,7 @@ load_dh_file(char *filename, bool isServerStart)
|
|||||||
ereport(isServerStart ? FATAL : LOG,
|
ereport(isServerStart ? FATAL : LOG,
|
||||||
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||||
errmsg("invalid DH parameters: p is not prime")));
|
errmsg("invalid DH parameters: p is not prime")));
|
||||||
|
DH_free(dh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
|
if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
|
||||||
@ -914,6 +916,7 @@ load_dh_file(char *filename, bool isServerStart)
|
|||||||
ereport(isServerStart ? FATAL : LOG,
|
ereport(isServerStart ? FATAL : LOG,
|
||||||
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||||
errmsg("invalid DH parameters: neither suitable generator or safe prime")));
|
errmsg("invalid DH parameters: neither suitable generator or safe prime")));
|
||||||
|
DH_free(dh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user