keyring search regression in master

NIIBE Yutaka gniibe at
Wed Nov 11 07:57:28 CET 2015

On 2015-11-11 at 12:11 +0900, NIIBE Yutaka wrote:
> # List with LONG-ID doesn't work
> $ gpg2 --homedir=/tmp/gpghome --list-key 79A79093084239CF
> gpg: error reading key: No public key

I think I located the problem, but I don't know how to fix.

It was introduced by the function check_user_ids.  It searches once,
and then, in the line 2198, it searches again.  Here, packets up to
the next PKT_PUBLIC_KEY will be skipped and subkeys are not registered
to the hash table.  Next time keyring_search will be called, the call
to lookup_offset_hash_table will fail (as the subkey is not
registered) and returns -1.

I think that this bug should be fixed before the release of 2.1.10.

I tried the following patch and it works well again, but this is
not the proper fix.

diff --git a/g10/keyring.c b/g10/keyring.c
index 81d2174..6756320 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -1056,7 +1056,7 @@ keyring_search (KEYRING_HANDLE hd,
           pk_no = uid_no = 0;
           initial_skip = 0;
-      if (initial_skip)
+      if (0 && initial_skip)
           free_packet (&pkt);

More information about the Gnupg-devel mailing list