[git] GnuPG - branch, master, updated. gnupg-2.1.2-7-ga8116aa
by Werner Koch
cvs at cvs.gnupg.org
Mon Feb 23 16:41:06 CET 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".
The branch, master has been updated
via a8116aacd91b7e775762a62c268fab6cc3c77438 (commit)
from d9f6eea6115df7959564123eb99d633ce5bba42e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a8116aacd91b7e775762a62c268fab6cc3c77438
Author: Werner Koch <wk at gnupg.org>
Date: Mon Feb 23 16:37:57 2015 +0100
gpg: Skip legacy keys while searching keyrings.
* g10/getkey.c (search_modes_are_fingerprint): New.
(lookup): Skip over legacy keys.
--
GnuPG-bug-id: 1847
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/g10/getkey.c b/g10/getkey.c
index 76ee493..116753c 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -2525,6 +2525,29 @@ found:
}
+/* Return true if all the search modes are fingerprints. */
+static int
+search_modes_are_fingerprint (getkey_ctx_t ctx)
+{
+ size_t n, found;
+
+ for (n=found=0; n < ctx->nitems; n++)
+ {
+ switch (ctx->items[n].mode)
+ {
+ case KEYDB_SEARCH_MODE_FPR16:
+ case KEYDB_SEARCH_MODE_FPR20:
+ case KEYDB_SEARCH_MODE_FPR:
+ found++;
+ break;
+ default:
+ break;
+ }
+ }
+ return found && found == ctx->nitems;
+}
+
+
/* The main function to lookup a key. On success the found keyblock
is stored at RET_KEYBLOCK and also in CTX. If WANT_SECRET is true
a corresponding secret key is required. */
@@ -2534,9 +2557,21 @@ lookup (getkey_ctx_t ctx, kbnode_t *ret_keyblock, int want_secret)
int rc;
int no_suitable_key = 0;
- rc = 0;
- while (!(rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems, NULL)))
+ for (;;)
{
+ rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems, NULL);
+ /* Skip over all legacy keys but only if they are not requested
+ by fingerprints.
+ Fixme: The lower level keydb code should actually do that but
+ then it would be harder to report the number of skipped
+ legacy keys during import. */
+ if (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY
+ && !(ctx->nitems && ctx->items->mode == KEYDB_SEARCH_MODE_FIRST)
+ && !search_modes_are_fingerprint (ctx))
+ continue;
+ if (rc)
+ break;
+
/* If we are searching for the first key we have to make sure
that the next iteration does not do an implicit reset.
This can be triggered by an empty key ring. */
-----------------------------------------------------------------------
Summary of changes:
g10/getkey.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list