[git] GnuPG - branch, master, updated. gnupg-2.1.14-69-ged5c1b0

by Werner Koch cvs at cvs.gnupg.org
Wed Aug 10 19:57:18 CEST 2016


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  ed5c1b0b8a4790c4fb36a3129387f7c2ef5db302 (commit)
       via  f2ea7e539c9a22081e3159dcbca84f57f30724ca (commit)
      from  a6acf1f6b39c5a607f61f643a5d21309ba58685d (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 ed5c1b0b8a4790c4fb36a3129387f7c2ef5db302
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Aug 10 19:51:54 2016 +0200

    gpg: Print the signer's UID during verification.
    
    * g10/parse-packet.c (parse_signature): Sanitize the value stored in
    SIGNERS_UID.
    * g10/mainproc.c (issuer_fpr_string): New.
    (check_sig_and_print): Print the signers' UID.  Print the issuer
    fingerprint in --rfc4880bis mode.
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/mainproc.c b/g10/mainproc.c
index e50e212..3d3f88b 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -1552,6 +1552,21 @@ akl_has_wkd_method (void)
 }
 
 
+/* Return the ISSUER fingerprint string in human readbale format if
+ * available.  Caller must release the string.  */
+static char *
+issuer_fpr_string (PKT_signature *sig)
+{
+  const byte *p;
+  size_t n;
+
+  p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_ISSUER_FPR, &n);
+  if (p && n == 21 && p[0] == 4)
+    return bin2hex (p+1, n-1, NULL);
+  return NULL;
+}
+
+
 static void
 print_good_bad_signature (int statno, const char *keyid_str, kbnode_t un,
                           PKT_signature *sig, int rc)
@@ -1589,6 +1604,7 @@ check_sig_and_print (CTX c, kbnode_t node)
   int is_expkey = 0;
   int is_revkey = 0;
   char pkstrbuf[PUBKEY_STRING_SIZE];
+  char *issuer_fpr;
 
   *pkstrbuf = 0;
 
@@ -1715,17 +1731,29 @@ check_sig_and_print (CTX c, kbnode_t node)
     write_status_text (STATUS_NEWSIG, NULL);
 
   astr = openpgp_pk_algo_name ( sig->pubkey_algo );
-  if (keystrlen () > 8)
+  if (opt.flags.rfc4880bis && (issuer_fpr = issuer_fpr_string (sig)))
+    {
+      log_info (_("Signature made %s\n"), asctimestamp(sig->timestamp));
+      log_info (_("               using %s key %s\n"),
+                astr? astr: "?", issuer_fpr);
+
+      xfree (issuer_fpr);
+    }
+  else if (!keystrlen () || keystrlen () > 8)
     {
       log_info (_("Signature made %s\n"), asctimestamp(sig->timestamp));
       log_info (_("               using %s key %s\n"),
                 astr? astr: "?", keystr(sig->keyid));
     }
-  else
+  else /* Legacy format.  */
     log_info (_("Signature made %s using %s key ID %s\n"),
               asctimestamp(sig->timestamp), astr? astr: "?",
               keystr(sig->keyid));
 
+  /* In verbose mode print the signers UID.  */
+  if (sig->signers_uid)
+    log_info (_("               issuer \"%s\"\n"), sig->signers_uid);
+
   rc = do_check_sig (c, node, NULL, &is_expkey, &is_revkey );
 
   /* If the key isn't found, check for a preferred keyserver.  */
diff --git a/g10/packet.h b/g10/packet.h
index 08e2cb7..9c9e909 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -231,7 +231,8 @@ typedef struct
   pka_info_t *pka_info;      /* Malloced PKA data or NULL if not
                                 available.  See also flags.pka_tried. */
   char *signers_uid;         /* Malloced value of the SIGNERS_UID
-                              * subpacket.  */
+                              * subpacket or NULL.  This string has
+                              * already been sanitized.  */
   subpktarea_t *hashed;      /* All subpackets with hashed data (v4 only). */
   subpktarea_t *unhashed;    /* Ditto for unhashed data. */
   /* First 2 bytes of the digest.  (Serialized.  Note: this is not
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index ec8a641..9a733b5 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1936,15 +1936,12 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen,
       p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_SIGNERS_UID, &len);
       if (p && len)
         {
-          sig->signers_uid = xtrymalloc (len+1);
+          sig->signers_uid = try_make_printable_string (p, len, 0);
           if (!sig->signers_uid)
             {
               rc = gpg_error_from_syserror ();
               goto leave;
             }
-          /* Note that we don't care about binary zeroes in the value.  */
-          memcpy (sig->signers_uid, p, len);
-          sig->signers_uid[len] = 0;
         }
 
       p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_NOTATION, NULL);

commit f2ea7e539c9a22081e3159dcbca84f57f30724ca
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Aug 10 19:04:43 2016 +0200

    common: New function try_make_printable_string.
    
    * common/stringhelp.c (sanitize_buffer): Remove.  Move code to ...
    * common/miscellaneous.c (try_make_printable_string): new.
    (make_printable_string): Call try_make_printable_string.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/miscellaneous.c b/common/miscellaneous.c
index 8d9a7aa..1327649 100644
--- a/common/miscellaneous.c
+++ b/common/miscellaneous.c
@@ -246,13 +246,77 @@ print_hexstring (FILE *fp, const void *buffer, size_t length, int reserved)
 #undef tohex
 }
 
+
+/* Create a string from the buffer P_ARG of length N which is suitable
+ * for printing.  Caller must release the created string using xfree.
+ * On error ERRNO is set and NULL returned.  Errors are only possible
+ * due to malloc failure.  */
 char *
-make_printable_string (const void *p, size_t n, int delim )
+try_make_printable_string (const void *p_arg, size_t n, int delim)
 {
-  return sanitize_buffer (p, n, delim);
+  const unsigned char *p = p_arg;
+  size_t save_n, buflen;
+  const unsigned char *save_p;
+  char *buffer, *d;
+
+  /* First count length. */
+  for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ )
+    {
+      if ( *p < 0x20 || *p == 0x7f || *p == delim  || (delim && *p=='\\'))
+        {
+          if ( *p=='\n' || *p=='\r' || *p=='\f'
+               || *p=='\v' || *p=='\b' || !*p )
+            buflen += 2;
+          else
+            buflen += 5;
+	}
+      else
+        buflen++;
+    }
+  p = save_p;
+  n = save_n;
+  /* And now make the string */
+  d = buffer = xtrymalloc (buflen);
+  for ( ; n; n--, p++ )
+    {
+      if (*p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) {
+        *d++ = '\\';
+        if( *p == '\n' )
+          *d++ = 'n';
+        else if( *p == '\r' )
+          *d++ = 'r';
+        else if( *p == '\f' )
+          *d++ = 'f';
+        else if( *p == '\v' )
+          *d++ = 'v';
+        else if( *p == '\b' )
+          *d++ = 'b';
+        else if( !*p )
+          *d++ = '0';
+        else {
+          sprintf(d, "x%02x", *p );
+          d += 3;
+        }
+      }
+      else
+        *d++ = *p;
+    }
+  *d = 0;
+  return buffer;
 }
 
 
+/* Same as try_make_printable_string but terminates the process on
+ * memory shortage.  */
+char *
+make_printable_string (const void *p, size_t n, int delim )
+{
+  char *string = try_make_printable_string (p, n, delim);
+  if (!string)
+    xoutofcore ();
+  return string;
+}
+
 
 /*
  * Check if the file is compressed.
diff --git a/common/stringhelp.c b/common/stringhelp.c
index 95912e0..990fc35 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -687,65 +687,6 @@ hextobyte (const char *s)
   return c;
 }
 
-
-/* Create a string from the buffer P_ARG of length N which is suitable
-   for printing.  Caller must release the created string using xfree.
-   This function terminates the process on memory shortage.  */
-char *
-sanitize_buffer (const void *p_arg, size_t n, int delim)
-{
-  const unsigned char *p = p_arg;
-  size_t save_n, buflen;
-  const unsigned char *save_p;
-  char *buffer, *d;
-
-  /* First count length. */
-  for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ )
-    {
-      if ( *p < 0x20 || *p == 0x7f || *p == delim  || (delim && *p=='\\'))
-        {
-          if ( *p=='\n' || *p=='\r' || *p=='\f'
-               || *p=='\v' || *p=='\b' || !*p )
-            buflen += 2;
-          else
-            buflen += 5;
-	}
-      else
-        buflen++;
-    }
-  p = save_p;
-  n = save_n;
-  /* And now make the string */
-  d = buffer = xmalloc( buflen );
-  for ( ; n; n--, p++ )
-    {
-      if (*p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) {
-        *d++ = '\\';
-        if( *p == '\n' )
-          *d++ = 'n';
-        else if( *p == '\r' )
-          *d++ = 'r';
-        else if( *p == '\f' )
-          *d++ = 'f';
-        else if( *p == '\v' )
-          *d++ = 'v';
-        else if( *p == '\b' )
-          *d++ = 'b';
-        else if( !*p )
-          *d++ = '0';
-        else {
-          sprintf(d, "x%02x", *p );
-          d += 3;
-        }
-      }
-      else
-        *d++ = *p;
-    }
-  *d = 0;
-  return buffer;
-}
-
-
 /* Given a string containing an UTF-8 encoded text, return the number
    of characters in this string.  It differs from strlen in that it
    only counts complete UTF-8 characters.  SIZE is the maximum length
diff --git a/common/stringhelp.h b/common/stringhelp.h
index b6f4167..adf2f20 100644
--- a/common/stringhelp.h
+++ b/common/stringhelp.h
@@ -61,9 +61,6 @@ int compare_filenames( const char *a, const char *b );
 
 int hextobyte (const char *s);
 
-char *sanitize_buffer (const void *p, size_t n, int delim);
-
-
 size_t utf8_charcount (const char *s, int len);
 
 
diff --git a/common/util.h b/common/util.h
index 3f2d174..6680414 100644
--- a/common/util.h
+++ b/common/util.h
@@ -287,6 +287,7 @@ void print_utf8_buffer2 (estream_t fp, const void *p, size_t n, int delim);
 void print_utf8_buffer (estream_t fp, const void *p, size_t n);
 void print_hexstring (FILE *fp, const void *buffer, size_t length,
                       int reserved);
+char *try_make_printable_string (const void *p, size_t n, int delim);
 char *make_printable_string (const void *p, size_t n, int delim);
 
 int is_file_compressed (const char *s, int *ret_rc);

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

Summary of changes:
 common/miscellaneous.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--
 common/stringhelp.c    | 59 -------------------------------------------
 common/stringhelp.h    |  3 ---
 common/util.h          |  1 +
 g10/mainproc.c         | 32 ++++++++++++++++++++++--
 g10/packet.h           |  3 ++-
 g10/parse-packet.c     |  5 +---
 7 files changed, 100 insertions(+), 71 deletions(-)


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




More information about the Gnupg-commits mailing list