gpg: Fix importing keys.
authorJustus Winter <justus@g10code.com>
Fri, 14 Jul 2017 09:17:49 +0000 (11:17 +0200)
committerJustus Winter <justus@g10code.com>
Fri, 14 Jul 2017 09:17:49 +0000 (11:17 +0200)
* g10/import.c (import_one): Fix error handling.

Fixes-commit: 330212efb927c119bb5135856f8582c0e4e2e6b7
Signed-off-by: Justus Winter <justus@g10code.com>
g10/import.c

index 8010fa5..1737479 100644 (file)
@@ -1627,9 +1627,12 @@ import_one (ctrl_t ctrl,
       if ( !(options & IMPORT_RESTORE) )
         {
           rc = apply_meta_data (keyblock, 0, origin);
-          log_error ("apply_meta_data failed: %s\n", gpg_strerror (rc));
-          keydb_release (hd);
-          return GPG_ERR_GENERAL;
+          if (rc)
+            {
+              log_error ("apply_meta_data failed: %s\n", gpg_strerror (rc));
+              keydb_release (hd);
+              return GPG_ERR_GENERAL;
+            }
         }
 
       rc = keydb_insert_keyblock (hd, keyblock );