mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
Address potential memory leak in openssldh_parse()
'dh' was being assigned to key->keydata.dh too soon which could result in a memory leak on error. Moved the assignement of key->keydata.dh until after dh was correct. Coverity was reporting dead code on the error path cleaning up 'dh' which triggered this review.
This commit is contained in:
@@ -1116,8 +1116,6 @@ openssldh_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
|
|||||||
DST_RET(ISC_R_NOMEMORY);
|
DST_RET(ISC_R_NOMEMORY);
|
||||||
}
|
}
|
||||||
DH_clear_flags(dh, DH_FLAG_CACHE_MONT_P);
|
DH_clear_flags(dh, DH_FLAG_CACHE_MONT_P);
|
||||||
key->keydata.dh = dh;
|
|
||||||
dh = NULL;
|
|
||||||
#else
|
#else
|
||||||
bld = OSSL_PARAM_BLD_new();
|
bld = OSSL_PARAM_BLD_new();
|
||||||
if (bld == NULL) {
|
if (bld == NULL) {
|
||||||
@@ -1155,11 +1153,11 @@ openssldh_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
if (DH_set0_key(key->keydata.dh, pub_key, priv_key) != 1) {
|
if (DH_set0_key(dh, pub_key, priv_key) != 1) {
|
||||||
DST_RET(dst__openssl_toresult2("DH_set0_key",
|
DST_RET(dst__openssl_toresult2("DH_set0_key",
|
||||||
DST_R_OPENSSLFAILURE));
|
DST_R_OPENSSLFAILURE));
|
||||||
}
|
}
|
||||||
if (DH_set0_pqg(key->keydata.dh, p, NULL, g) != 1) {
|
if (DH_set0_pqg(dh, p, NULL, g) != 1) {
|
||||||
DST_RET(dst__openssl_toresult2("DH_set0_pqg",
|
DST_RET(dst__openssl_toresult2("DH_set0_pqg",
|
||||||
DST_R_OPENSSLFAILURE));
|
DST_R_OPENSSLFAILURE));
|
||||||
}
|
}
|
||||||
@@ -1169,6 +1167,9 @@ openssldh_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
|
|||||||
priv_key = NULL;
|
priv_key = NULL;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
g = NULL;
|
g = NULL;
|
||||||
|
|
||||||
|
key->keydata.dh = dh;
|
||||||
|
dh = NULL;
|
||||||
#else
|
#else
|
||||||
if (OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub_key) !=
|
if (OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub_key) !=
|
||||||
1 ||
|
1 ||
|
||||||
|
Reference in New Issue
Block a user