Skip to content

Commit

Permalink
checkKey: handle NULL error string from OpenSSL more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Habbie committed Aug 10, 2021
1 parent c5f74c4 commit 843bc50
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pdns/opensslsigners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ bool OpenSSLRSADNSCryptoKeyEngine::checkKey(vector<string> *errorMessages) const
if (RSA_check_key(d_key.get()) != 1) {
retval = false;
if (errorMessages != nullptr) {
errorMessages->push_back(ERR_reason_error_string(ERR_get_error()));
auto errmsg = ERR_reason_error_string(ERR_get_error());
if (errmsg == nullptr) {
errmsg = "Unknown OpenSSL error";
}
errorMessages->push_back(errmsg);
}
}
return retval;
Expand Down Expand Up @@ -802,7 +806,11 @@ bool OpenSSLECDSADNSCryptoKeyEngine::checkKey(vector<string> *errorMessages) con
if (EC_KEY_check_key(d_eckey.get()) != 1) {
retval = false;
if (errorMessages != nullptr) {
errorMessages->push_back(ERR_reason_error_string(ERR_get_error()));
auto errmsg = ERR_reason_error_string(ERR_get_error());
if (errmsg == nullptr) {
errmsg = "Unknown OpenSSL error";
}
errorMessages->push_back(errmsg);
}
}
return retval;
Expand Down

0 comments on commit 843bc50

Please sign in to comment.