[Pkg-gnupg-commit] [gnupg2] 103/159: gpg: Fix NULL de-ref for ambiguous key check in --export-ssh-keys.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Jan 27 13:23:59 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 b280aa6423c9492e8c5a9afa57339d06d957996d
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jan 11 10:59:13 2016 +0100

    gpg: Fix NULL de-ref for ambiguous key check in --export-ssh-keys.
    
    * g10/getkey.c: Allow arg RET_KEYBLOCK to be NULL.
    --
    
    This change adds the expected behavior for the getkey_next function
    to fix this NULL de-ref.
    
    GnuPG-bug-id: 2212
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 g10/getkey.c | 6 +++++-
 g10/keydb.h  | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/g10/getkey.c b/g10/getkey.c
index 37a5b56..1df7287 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -3059,6 +3059,9 @@ lookup (getkey_ctx_t ctx, kbnode_t *ret_keyblock, kbnode_t *ret_found_key,
   KBNODE keyblock = NULL;
   KBNODE found_key = NULL;
 
+  if (ret_keyblock)
+    *ret_keyblock = NULL;
+
   for (;;)
     {
       rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems, NULL);
@@ -3113,7 +3116,8 @@ found:
 
   if (!rc)
     {
-      *ret_keyblock = keyblock; /* Return the keyblock.  */
+      if (ret_keyblock)
+        *ret_keyblock = keyblock; /* Return the keyblock.  */
       keyblock = NULL;
     }
   else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND && no_suitable_key)
diff --git a/g10/keydb.h b/g10/keydb.h
index f99136a..41d786c 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -750,6 +750,11 @@ gpg_error_t getkey_byname (ctrl_t ctrl,
    can use free_public_key, which calls release_public_key_parts(PK)
    and then xfree(PK)).
 
+   RET_KEYBLOCK can be given as NULL; if it is not NULL it the entire
+   found keyblock wis retruned hich must be released with
+   release_kbnode.  If the function returns an error NULL is stored at
+   RET_KEYBLOCK.
+
    The self-signed data has already been merged into the public key
    using merge_selfsigs.  */
 gpg_error_t getkey_next (getkey_ctx_t ctx, PKT_public_key *pk,

-- 
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