mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
g10: Fix iteration over getkey results.
* g10/getkey.c (getkey_next): Fix invocation of 'lookup'. If we want to use RET_FOUND_KEY, RET_KEYBLOCK must be valid. Fixes-commit: 8ea72a776a88f3c851e812d258355be80caa1bc1 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
bd60742925
commit
1d03cc77e1
@ -2167,6 +2167,7 @@ gpg_error_t
|
|||||||
getkey_next (getkey_ctx_t ctx, PKT_public_key *pk, kbnode_t *ret_keyblock)
|
getkey_next (getkey_ctx_t ctx, PKT_public_key *pk, kbnode_t *ret_keyblock)
|
||||||
{
|
{
|
||||||
int rc; /* Fixme: Make sure this is proper gpg_error */
|
int rc; /* Fixme: Make sure this is proper gpg_error */
|
||||||
|
KBNODE keyblock = NULL;
|
||||||
KBNODE found_key = NULL;
|
KBNODE found_key = NULL;
|
||||||
|
|
||||||
/* We need to disable the caching so that for an exact key search we
|
/* We need to disable the caching so that for an exact key search we
|
||||||
@ -2175,11 +2176,18 @@ getkey_next (getkey_ctx_t ctx, PKT_public_key *pk, kbnode_t *ret_keyblock)
|
|||||||
used without respecting the current file pointer! */
|
used without respecting the current file pointer! */
|
||||||
keydb_disable_caching (ctx->kr_handle);
|
keydb_disable_caching (ctx->kr_handle);
|
||||||
|
|
||||||
|
/* FOUND_KEY is only valid as long as RET_KEYBLOCK is. If the
|
||||||
|
* caller wants PK, but not RET_KEYBLOCK, we need hand in our own
|
||||||
|
* keyblock. */
|
||||||
|
if (pk && ret_keyblock == NULL)
|
||||||
|
ret_keyblock = &keyblock;
|
||||||
|
|
||||||
rc = lookup (ctx, ret_keyblock, &found_key, ctx->want_secret);
|
rc = lookup (ctx, ret_keyblock, &found_key, ctx->want_secret);
|
||||||
if (!rc && pk)
|
if (!rc && pk)
|
||||||
{
|
{
|
||||||
log_assert (found_key);
|
log_assert (found_key);
|
||||||
pk_from_block (pk, NULL, found_key);
|
pk_from_block (pk, NULL, found_key);
|
||||||
|
release_kbnode (keyblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user