Do not free p and g parameters after calling DH_set0_pqg(3).

It is specifically mentioned in the manual page.  Note it has no functional
change in reality because DH_set0_pqg() cannot fail when both p and g are
not NULL.
This commit is contained in:
Jung-uk Kim 2020-02-27 22:36:16 +00:00
parent a33b334336
commit a5f8e6f658

View File

@ -83,20 +83,24 @@ static unsigned char dh512_g[] =
static DH *
get_dh512()
{
DH *dh = NULL;
DH *dh;
BIGNUM *dhp_bn, *dhg_bn;
if ((dh = DH_new()) == NULL)
return NULL;
dhp_bn = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
dhg_bn = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
if ((dhp_bn == NULL) || (dhg_bn == NULL) || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
if ((dhp_bn == NULL) || (dhg_bn == NULL))
{
DH_free(dh);
BN_free(dhp_bn);
BN_free(dhg_bn);
return NULL;
}
if (!DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
{
DH_free(dh);
return NULL;
}
return dh;
}
@ -149,13 +153,17 @@ get_dh2048()
return NULL;
dhp_bn = BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL);
dhg_bn = BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL);
if ((dhp_bn == NULL) || (dhg_bn == NULL) || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
if ((dhp_bn == NULL) || (dhg_bn == NULL))
{
DH_free(dh);
BN_free(dhp_bn);
BN_free(dhg_bn);
return NULL;
}
if (!DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
{
DH_free(dh);
return NULL;
}
return dh;
}
# endif /* !NO_DH */