aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-07-17 11:24:51 +0000
committerWerner Koch <[email protected]>2009-07-17 11:24:51 +0000
commitb47838975388294154c7248b9a6592b76654c7c1 (patch)
treeb2cdcf4d8b558c4cbd9411cbea2bd0028d0fcbe0
parentFix bug#1087. (diff)
downloadgnupg-b47838975388294154c7248b9a6592b76654c7c1.tar.gz
gnupg-b47838975388294154c7248b9a6592b76654c7c1.zip
Repalce an assert by a proper error message.
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/keyring.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 1691b5800..68cf2d9ba 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-17 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* misc.c (has_invalid_email_chars): Let non-ascii characters pass
diff --git a/g10/keyring.c b/g10/keyring.c
index ee6509678..4dc662ed9 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -1399,7 +1399,20 @@ keyring_rebuild_cache (void *token,int noisy)
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)