g10: Fix iteration over getkey results.
authorJustus Winter <justus@g10code.com>
Mon, 28 Nov 2016 12:36:56 +0000 (13:36 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 28 Nov 2016 12:48:19 +0000 (13:48 +0100)
* g10/getkey.c (getkey_next): Only ask 'lookup' for the exact match if
our caller requested the key.  Fixes a crash in 'lookup'.

GnuPG-bug-id: 2848
Fixes-commit: 1d03cc77e1706f7da653153ad4b58c61e4fd2573
Signed-off-by: Justus Winter <justus@g10code.com>
g10/getkey.c

index 68e6a1b..6eec087 100644 (file)
@@ -2178,7 +2178,7 @@ getkey_next (getkey_ctx_t ctx, PKT_public_key *pk, kbnode_t *ret_keyblock)
   if (pk && ret_keyblock == NULL)
       ret_keyblock = &keyblock;
 
-  rc = lookup (ctx, ret_keyblock, &found_key, ctx->want_secret);
+  rc = lookup (ctx, ret_keyblock, pk ? &found_key : NULL, ctx->want_secret);
   if (!rc && pk)
     {
       log_assert (found_key);