Fix a use-after-free crash

When requesting revocation AND deletion of certificates while renewing
them, revocation occurs after deletion, causing a use-after-free
error/crash.

This commit delays the certificates deletion after they have been
revoked.
This commit is contained in:
Patrick Monnerat 2024-01-22 08:49:47 +01:00
parent 89b3914ff7
commit 5dc8e7fd34

View File

@ -765,13 +765,15 @@ void db_x509::certRenewal(QModelIndexList indexes)
newcert->sign(signkey, oldcert->getDigest());
newcert = dynamic_cast<pki_x509 *>(insert(newcert));
createSuccess(newcert);
// delete old certificate if requested
if (doReplace)
deletePKI(idx);
}
if (doRevoke)
do_revoke(indexes, r);
// delete old certificates if requested
if (doReplace)
foreach(idx, indexes)
if (fromIndex<pki_x509>(idx))
deletePKI(idx);
}
catch (errorEx &err) {
XCA_ERROR(err);