cpp: Add safety checks for key update
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 24 Jul 2018 06:40:28 +0000 (08:40 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 24 Jul 2018 06:40:28 +0000 (08:40 +0200)
* 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.

lang/cpp/src/key.cpp
lang/cpp/src/verificationresult.cpp

index 61b3eb7..8fc266f 100644 (file)
@@ -347,6 +347,9 @@ const Key &Key::mergeWith(const Key &other)
 
 void Key::update()
 {
+    if (isNull() || !primaryFingerprint()) {
+        return;
+    }
     auto ctx = Context::createForProtocol(protocol());
     if (!ctx) {
         return;
index 2c42d07..fa8237a 100644 (file)
@@ -406,7 +406,7 @@ GpgME::Key GpgME::Signature::key(bool search, bool update) const
     }
 
     GpgME::Key ret = key();
-    if (ret.isNull() && search) {
+    if (ret.isNull() && search && fingerprint ()) {
         auto ctx = Context::createForProtocol (d->proto);
         if (ctx) {
             ctx->setKeyListMode(KeyListMode::Local |