cpp: Add safety checks for key update

* lang/cpp/src/key.cpp (Key::update): Check that the key is
not NULL.
* lang/cpp/src/verificationresult.cpp (GpgME::Signature::key):
Check for fingerprint.
This commit is contained in:
Andre Heinecke 2018-07-24 08:40:28 +02:00
parent 4d1642b11e
commit a6e5c8bf18
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C
2 changed files with 4 additions and 1 deletions

View File

@ -347,6 +347,9 @@ const Key &Key::mergeWith(const Key &other)
void Key::update() void Key::update()
{ {
if (isNull() || !primaryFingerprint()) {
return;
}
auto ctx = Context::createForProtocol(protocol()); auto ctx = Context::createForProtocol(protocol());
if (!ctx) { if (!ctx) {
return; return;

View File

@ -406,7 +406,7 @@ GpgME::Key GpgME::Signature::key(bool search, bool update) const
} }
GpgME::Key ret = key(); GpgME::Key ret = key();
if (ret.isNull() && search) { if (ret.isNull() && search && fingerprint ()) {
auto ctx = Context::createForProtocol (d->proto); auto ctx = Context::createForProtocol (d->proto);
if (ctx) { if (ctx) {
ctx->setKeyListMode(KeyListMode::Local | ctx->setKeyListMode(KeyListMode::Local |