Add missing checks for X509 parsing failures

This commit is contained in:
Cameron Gutman committed 2026-10-14 01:39:00 -05:00
1 parent fa6ae80940
commit 2bd4b9f721
1 file changed
+10 -1
+10 -1
View File
@@ -140,6 +140,9 @@ NvPairingManager::getSignatureFromPemCert(const QByteArray& certificate)
X509* cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
BIO_free_all(bio);
if (cert == nullptr) {
return QByteArray();
}
QByteArray signature = getSignatureFromCert(cert);
X509_free(cert);
@@ -159,9 +162,15 @@ NvPairingManager::verifySignature(const QByteArray& data, const QByteArray& sign
X509* cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
BIO_free_all(bio);
if (cert == nullptr) {
return false;
}
EVP_PKEY* pubKey = X509_get_pubkey(cert);
THROW_BAD_ALLOC_IF_NULL(pubKey);
if (pubKey == nullptr) {
X509_free(cert);
return false;
}
EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
THROW_BAD_ALLOC_IF_NULL(mdctx);