[svn] GnuPG - r5081 - branches/STABLE-BRANCH-1-4/g10

svn author wk cvs at cvs.gnupg.org
Fri Jul 17 13:24:52 CEST 2009


Author: wk
Date: 2009-07-17 13:24:51 +0200 (Fri, 17 Jul 2009)
New Revision: 5081

Modified:
   branches/STABLE-BRANCH-1-4/g10/ChangeLog
   branches/STABLE-BRANCH-1-4/g10/keyring.c
Log:
Repalce an assert by a proper error message.


Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-07-16 15:54:59 UTC (rev 5080)
+++ branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-07-17 11:24:51 UTC (rev 5081)
@@ -1,3 +1,8 @@
+2009-07-17  Werner Koch  <wk at g10code.com>
+
+	* keyring.c (keyring_rebuild_cache): Replace the assert by a
+	proper error message and allow to delete a bad keyblock.
+
 2009-07-16  Werner Koch  <wk at g10code.com>
 
 	* misc.c (has_invalid_email_chars): Let non-ascii characters pass

Modified: branches/STABLE-BRANCH-1-4/g10/keyring.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/keyring.c	2009-07-16 15:54:59 UTC (rev 5080)
+++ branches/STABLE-BRANCH-1-4/g10/keyring.c	2009-07-17 11:24:51 UTC (rev 5081)
@@ -1399,7 +1399,20 @@
           log_error ("keyring_get_keyblock failed: %s\n", g10_errstr(rc));
           goto leave;
         }
-      assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
+      if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
+        {
+          /* We had a few reports about corrupted keyrings; if we have
+             been called directly from the command line we delete such
+             a keyblock instead of bailing out.  */
+          log_error ("unexpected keyblock found (pkttype=%d)%s\n",
+                     keyblock->pkt->pkttype, noisy? " - deleted":"");
+          if (noisy)
+            continue;
+          log_info ("Hint: backup your keys and try running `%s'\n",
+                    "gpg --rebuild-keydb-caches");
+          rc = G10ERR_INV_KEYRING;
+          goto leave;
+        }
 
       /* check all signature to set the signature's cache flags */
       for (node=keyblock; node; node=node->next)




More information about the Gnupg-commits mailing list