[Pkg-gnupg-commit] [gnupg2] 210/292: g10: Fix crash.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 5840353d8bbcd9e75374f3bdb2547ffa7bbea897
Author: Justus Winter <justus at g10code.com>
Date:   Mon Nov 7 12:53:17 2016 +0100

    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 at g10code.com>
---
 g10/getkey.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/g10/getkey.c b/g10/getkey.c
index 648c230..59625e7 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1577,18 +1577,19 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
   int rc;
   struct getkey_ctx_s *ctx = NULL;
 
+  if (retctx)
+    *retctx = NULL;
+
   rc = get_pubkey_byname (ctrl, &ctx, pk, name, ret_keyblock,
                           NULL, include_unusable, no_akl);
   if (rc)
     {
       if (ctx)
         getkey_end (ctx);
-      if (retctx)
-        *retctx = NULL;
       return rc;
     }
 
-  if (is_valid_mailbox (name))
+  if (is_valid_mailbox (name) && ctx)
     {
       /* Rank results and return only the most relevant key.  */
       struct pubkey_cmp_cookie best = { 0 }, new;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list