Skip to content

Commit

Permalink
Remove duplicit error check in engine key loading
Browse files Browse the repository at this point in the history
ldns_key_set_algorithm cannot change state of the key. Check it only
once, return specialized error code if failed.
  • Loading branch information
pemensik committed Jul 19, 2024
1 parent 51dedf3 commit ef77ff8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef77ff8

Please sign in to comment.