mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-26 22:29:58 +01:00
g10: Fix crash.
* g10/getkey.c (get_best_pubkey_byname): If 'get_pubkey_byname' does not return a getkey context, then it can return at most one key, therefore there is nothing to rank. Also, always initialize '*retctx' to be on the safe side. GnuPG-bug-id: 2828 Fixes: ab89164be02012f1bf159c971853b8610e966301 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
4d7dc432b5
commit
5840353d8b
@ -1577,18 +1577,19 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
|||||||
int rc;
|
int rc;
|
||||||
struct getkey_ctx_s *ctx = NULL;
|
struct getkey_ctx_s *ctx = NULL;
|
||||||
|
|
||||||
|
if (retctx)
|
||||||
|
*retctx = NULL;
|
||||||
|
|
||||||
rc = get_pubkey_byname (ctrl, &ctx, pk, name, ret_keyblock,
|
rc = get_pubkey_byname (ctrl, &ctx, pk, name, ret_keyblock,
|
||||||
NULL, include_unusable, no_akl);
|
NULL, include_unusable, no_akl);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
if (ctx)
|
if (ctx)
|
||||||
getkey_end (ctx);
|
getkey_end (ctx);
|
||||||
if (retctx)
|
|
||||||
*retctx = NULL;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_valid_mailbox (name))
|
if (is_valid_mailbox (name) && ctx)
|
||||||
{
|
{
|
||||||
/* Rank results and return only the most relevant key. */
|
/* Rank results and return only the most relevant key. */
|
||||||
struct pubkey_cmp_cookie best = { 0 }, new;
|
struct pubkey_cmp_cookie best = { 0 }, new;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user