[git] GnuPG - branch, master, updated. gnupg-2.1.9-169-ge9c16fe

by Neal H. Walfield cvs at cvs.gnupg.org
Tue Nov 24 13:03:30 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  e9c16fee2576c772de9d4fb5d53fee28e4b84202 (commit)
      from  19362a8dd7ee986c082a5afc5a446f939991ec0f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e9c16fee2576c772de9d4fb5d53fee28e4b84202
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Nov 24 13:03:24 2015 +0100

    gpg: When comparing keyids, use the keyid, not the fingerprint's suffix.
    
    * g10/keyedit.c (menu_select_key): Use spacep and hexdigitp instead of
    inline tests.  Don't compare P to the suffix of the fingerprint.  If P
    appears to be a keyid, do an exact compare against the keyid.  If it
    appears to be a fingerprint, do an exact compare against the
    fingerprint.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/keyedit.c b/g10/keyedit.c
index 1511c17..9cf6f44 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -4916,15 +4916,20 @@ menu_select_key (KBNODE keyblock, int idx, char *p)
   is_hex_digits = p && strlen (p) >= 8;
   if (is_hex_digits)
     {
+      /* Skip initial spaces.  */
+      while (spacep (p))
+        p ++;
+      /* If the id starts with 0x accept and ignore it.  */
+      if (p[0] == '0' && p[1] == 'x')
+        p += 2;
+
       for (i = 0, j = 0; p[i]; i ++)
-        if (('0' <= p[i] && p[i] <= '9')
-            || ('A' <= p[i] && p[i] <= 'F')
-            || ('a' <= p[i] && p[i] <= 'f'))
+        if (hexdigitp (&p[i]))
           {
             p[j] = toupper (p[i]);
             j ++;
           }
-        else if (p[i] == ' ')
+        else if (spacep (&p[i]))
           /* Skip spaces.  */
           {
           }
@@ -4939,7 +4944,13 @@ menu_select_key (KBNODE keyblock, int idx, char *p)
           p[j] = 0;
           /* If we skipped some spaces, make sure that we still have
              at least 8 characters.  */
-          is_hex_digits = strlen (p) >= 8;
+          is_hex_digits = (/* Short keyid.  */
+                           strlen (p) == 8
+                           /* Long keyid.  */
+                           || strlen (p) == 16
+                           /* Fingerprints are (currently) 32 or 40
+                              characters.  */
+                           || strlen (p) >= 32);
         }
     }
 
@@ -4950,14 +4961,32 @@ menu_select_key (KBNODE keyblock, int idx, char *p)
 	if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
 	    || node->pkt->pkttype == PKT_SECRET_SUBKEY)
           {
-            char fp[2*MAX_FINGERPRINT_LEN + 1];
-            hexfingerprint (node->pkt->pkt.public_key, fp, sizeof (fp));
-            if (strcmp (&fp[strlen (fp) - strlen (p)], p) == 0)
+            int match = 0;
+            if (strlen (p) == 8 || strlen (p) == 16)
               {
-		if ((node->flag & NODFLG_SELKEY))
-		  node->flag &= ~NODFLG_SELKEY;
-		else
-		  node->flag |= NODFLG_SELKEY;
+                u32 kid[2];
+                char kid_str[17];
+                keyid_from_pk (node->pkt->pkt.public_key, kid);
+                format_keyid (kid, strlen (p) == 8 ? KF_SHORT : KF_LONG,
+                              kid_str, sizeof (kid_str));
+
+                if (strcmp (p, kid_str) == 0)
+                  match = 1;
+              }
+            else
+              {
+                char fp[2*MAX_FINGERPRINT_LEN + 1];
+                hexfingerprint (node->pkt->pkt.public_key, fp, sizeof (fp));
+                if (strcmp (fp, p) == 0)
+                  match = 1;
+              }
+
+            if (match)
+              {
+                if ((node->flag & NODFLG_SELKEY))
+                  node->flag &= ~NODFLG_SELKEY;
+                else
+                  node->flag |= NODFLG_SELKEY;
 
                 found_one = 1;
               }

-----------------------------------------------------------------------

Summary of changes:
 g10/keyedit.c | 53 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list