[Pkg-gnupg-commit] [gnupg2] 99/159: gpg: Add an exact search flag to the PK struct.

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 34bca9cd4b8517795833cb754b0d5b1dd33b08ed
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 8 15:16:12 2016 +0100

    gpg: Add an exact search flag to the PK struct.
    
    * g10/getkey.c (merge_selfsigs_subkey): Clear exact flag.
    (finish_lookup): Set exact flag.
    * g10/packet.h (PKT_public_key): Add field flags.exact.
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 g10/getkey.c | 10 ++++++----
 g10/packet.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/g10/getkey.c b/g10/getkey.c
index e66be0d..37a5b56 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -2510,6 +2510,7 @@ merge_selfsigs_subkey (KBNODE keyblock, KBNODE subnode)
   keytimestamp = subpk->timestamp;
 
   subpk->flags.valid = 0;
+  subpk->flags.exact = 0;
   subpk->main_keyid[0] = mainpk->main_keyid[0];
   subpk->main_keyid[1] = mainpk->main_keyid[1];
 
@@ -2836,6 +2837,8 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock)
 
   u32 latest_date;
   KBNODE latest_key;
+  PKT_public_key *pk;
+
 
   assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
 
@@ -2850,6 +2853,8 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock)
 	      assert (k->pkt->pkttype == PKT_PUBLIC_KEY
 		      || k->pkt->pkttype == PKT_PUBLIC_SUBKEY);
 	      foundk = k;
+              pk = k->pkt->pkt.public_key;
+              pk->flags.exact = 1;
 	      break;
 	    }
 	}
@@ -2893,8 +2898,6 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock)
       /* Either start a loop or check just this one subkey.  */
       for (k = foundk ? foundk : keyblock; k; k = nextk)
 	{
-	  PKT_public_key *pk;
-
 	  if (foundk)
 	    /* If FOUNDK is not NULL, then only consider that exact
 	       key, i.e., don't iterate.  */
@@ -2968,7 +2971,6 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock)
        - we're just considering the primary key.  */
   if ((!latest_key && !ctx->exact) || foundk == keyblock || req_prim)
     {
-      PKT_public_key *pk;
       if (DBG_LOOKUP && !foundk && !req_prim)
 	log_debug ("\tno suitable subkeys found - trying primary\n");
       pk = keyblock->pkt->pkt.public_key;
@@ -3015,7 +3017,7 @@ found:
 
   if (latest_key)
     {
-      PKT_public_key *pk = latest_key->pkt->pkt.public_key;
+      pk = latest_key->pkt->pkt.public_key;
       if (pk->user_id)
 	free_user_id (pk->user_id);
       pk->user_id = scopy_user_id (foundu);
diff --git a/g10/packet.h b/g10/packet.h
index 9eb16cf..16524f8 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -298,6 +298,7 @@ typedef struct
     unsigned int dont_cache:1;    /* Do not cache this key.  */
     unsigned int backsig:2;       /* 0=none, 1=bad, 2=good.  */
     unsigned int serialno_valid:1;/* SERIALNO below is valid.  */
+    unsigned int exact:1;         /* Found via exact (!) search.  */
   } flags;
   PKT_user_id *user_id;   /* If != NULL: found by that uid. */
   struct revocation_key *revkey;

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