Commit 29b3f108 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Prevent crash when revoking certifications without certification key

Do not start a job for revoking signatures if no certification key
or no user IDs were selected. And prevent a nullptr-dereference if
the job creation failed for some reason.

GnuPG-bug-id: 5858
parent 7c59b266
......@@ -54,7 +54,7 @@ private:
private:
void ensureDialogCreated();
void createJob();
QGpgME::QuickJob *createJob();
private:
Key certificationKey;
......@@ -101,8 +101,20 @@ void RevokeCertificationCommand::Private::init()
void RevokeCertificationCommand::Private::slotDialogAccepted()
{
createJob();
const auto certificationKey = dialog->selectedCertificationKey();
const auto selectedUserIDs = dialog->selectedUserIDs();
if (certificationKey.isNull() || selectedUserIDs.empty()) {
qCDebug(KLEOPATRA_LOG) << "No certification key or no user IDs selected -> skipping revocation";
finished();
return;
}
job = createJob();
if (!job) {
qCDebug(KLEOPATRA_LOG) << "Failed to create QuickJob";
finished();
return;
}
job->startRevokeSignature(certificationTarget, dialog->selectedCertificationKey(), dialog->selectedUserIDs());
}
......@@ -147,27 +159,25 @@ void RevokeCertificationCommand::Private::ensureDialogCreated()
connect(dialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected()));
}
void RevokeCertificationCommand::Private::createJob()
QGpgME::QuickJob *RevokeCertificationCommand::Private::createJob()
{
Q_ASSERT(!job);
Q_ASSERT(certificationTarget.protocol() == OpenPGP);
const auto backend = QGpgME::openpgp();
if (!backend) {
return;
return nullptr;
}
QuickJob *const j = backend->quickJob();
if (!j) {
return;
if (j) {
connect(j, &Job::progress,
q, &Command::progress);
connect(j, SIGNAL(result(GpgME::Error)),
q, SLOT(slotResult(GpgME::Error)));
}
connect(j, &Job::progress,
q, &Command::progress);
connect(j, SIGNAL(result(GpgME::Error)),
q, SLOT(slotResult(GpgME::Error)));
job = j;
return j;
}
RevokeCertificationCommand::RevokeCertificationCommand(QAbstractItemView *v, KeyListController *c)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment