From ef77ff8ac9be564ba8f9ba746574d6bbedbd8749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Fri, 19 Jul 2024 15:45:09 +0200 Subject: [PATCH] Remove duplicit error check in engine key loading ldns_key_set_algorithm cannot change state of the key. Check it only once, return specialized error code if failed. --- keys.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/keys.c b/keys.c index b0927391..8125de3f 100644 --- a/keys.c +++ b/keys.c @@ -120,16 +120,12 @@ ldns_key_new_frm_engine(ldns_key **key, ENGINE *e, char *key_id, ldns_algorithm k = ldns_key_new(); if(!k) return LDNS_STATUS_MEM_ERR; #ifndef S_SPLINT_S - k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL); - if(!k->_key.key) { - ldns_key_free(k); - return LDNS_STATUS_ERR; - } ldns_key_set_algorithm(k, (ldns_signing_algorithm) alg); + k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL); if (!k->_key.key) { ldns_key_free(k); return LDNS_STATUS_ENGINE_KEY_NOT_LOADED; - } + } #endif /* splint */ *key = k; return LDNS_STATUS_OK;