[git] GnuPG - branch, master, updated. gnupg-2.1.15-270-g9d6146d

by Werner Koch cvs at cvs.gnupg.org
Mon Oct 24 13:16:07 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  9d6146d6f9870fbfcec15cdc4becaf094d5a90e0 (commit)
       via  8c40b3b98d3ddeda79fde981e6539c5b3b09d9a2 (commit)
       via  fdb653a33ea1a24d1159880624dbbcc0867865b5 (commit)
      from  5e7dfd979d2d91800d90c3ce9a66755df3217682 (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 9d6146d6f9870fbfcec15cdc4becaf094d5a90e0
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Oct 24 13:12:05 2016 +0200

    gpg: Replace two sprintf calls.
    
    * g10/keygen.c (print_status_key_created): Use snprintf for now.
    (ask_expire_interval): Replace xmalloc and sprintf by xasprintf.
    --
    
    Future updates: Replace code like
    
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pKEYLENGTH;
       sprintf( r->u.value, "%u", info.key_attr[0].nbits);
    
    by something like
    
       r = new_r_with_value ("%u", info.key_attr[0].nbits);
       r->key = pKEYLENGTH;
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/keygen.c b/g10/keygen.c
index ed529c7..d98b70b 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -180,8 +180,9 @@ print_status_key_created (int letter, PKT_public_key *pk, const char *handle)
           *p++ = ' ';
           fingerprint_from_pk (pk, array, &n);
           s = array;
+          /* Fixme: Use bin2hex */
           for (i=0; i < n ; i++, s++, p += 2)
-            sprintf (p, "%02X", *s);
+            snprintf (p, 3, "%02X", *s);
         }
     }
   if (*handle)
@@ -2428,13 +2429,7 @@ ask_expire_interval(int object,const char *def_expire)
 	  {
 	    char *prompt;
 
-#define PROMPTSTRING _("Signature is valid for? (%s) ")
-	    /* This will actually end up larger than necessary because
-	       of the 2 bytes for '%s' */
-	    prompt=xmalloc(strlen(PROMPTSTRING)+strlen(def_expire)+1);
-	    sprintf(prompt,PROMPTSTRING,def_expire);
-#undef PROMPTSTRING
-
+	    prompt = xasprintf (_("Signature is valid for? (%s) "), def_expire);
 	    answer = cpr_get("siggen.valid",prompt);
 	    xfree(prompt);
 

commit 8c40b3b98d3ddeda79fde981e6539c5b3b09d9a2
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Oct 24 13:01:06 2016 +0200

    agent: Minor cleanup for recent change in findkey.c
    
    * agent/findkey.c (agent_write_private_key): Avoid label name error.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/findkey.c b/agent/findkey.c
index 162e8c2..c67dc72 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -157,14 +157,10 @@ agent_write_private_key (const unsigned char *grip,
         {
           fp = es_fopen (fname, "wbx,mode=-rw");
           if (!fp)
-            {
-              tmperr = gpg_error_from_syserror ();
-              goto error;
-            }
+            tmperr = gpg_error_from_syserror ();
         }
-      else
+      if (!fp)
         {
-        error:
           log_error ("can't create '%s': %s\n", fname, gpg_strerror (tmperr));
           xfree (fname);
           return tmperr;

commit fdb653a33ea1a24d1159880624dbbcc0867865b5
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Oct 24 12:55:21 2016 +0200

    agent: Slightly change structure of cmd_readkey.
    
    * agent/command.c (cmd_readkey): Avoid a leave label in the middle of
    the code.  Remove the special return.
    --
    
    This helps to get better debug output.
    
    The set_error macro which is used by parse_keygrip merely sets the
    error code into the Assuan context.  It is thus no problem anymore to
    call leave_cmd after having used set_error.  This might havve been
    diffferent in the past.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/command.c b/agent/command.c
index 1a13084..999f608 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -391,7 +391,9 @@ progress_cb (ctrl_t ctrl, const char *what, int printchar,
 }
 
 
-/* Helper to print a message while leaving a command.  */
+/* Helper to print a message while leaving a command.  Note that this
+ * function does not call assuan_set_error; the caller may do this
+ * prior to calling us.  */
 static gpg_error_t
 leave_cmd (assuan_context_t ctx, gpg_error_t err)
 {
@@ -1000,17 +1002,19 @@ cmd_readkey (assuan_context_t ctx, char *line)
   unsigned char grip[20];
   gcry_sexp_t s_pkey = NULL;
   unsigned char *pkbuf = NULL;
+  char *serialno = NULL;
   size_t pkbuflen;
+  const char *opt_card;
 
   if (ctrl->restricted)
     return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
 
-  if (has_option_name (line, "--card"))
-    {
-      const char *keyid;
-      char *serialno = NULL;
+  opt_card = has_option_name (line, "--card");
+  line = skip_options (line);
 
-      keyid = skip_options (line);
+  if (opt_card)
+    {
+      const char *keyid = opt_card;
 
       rc = agent_card_getattr (ctrl, "SERIALNO", &serialno);
       if (rc)
@@ -1042,35 +1046,33 @@ cmd_readkey (assuan_context_t ctx, char *line)
         goto leave;
 
       rc = assuan_send_data (ctx, pkbuf, pkbuflen);
-
- leave:
-      xfree (serialno);
-      xfree (pkbuf);
-      gcry_sexp_release (s_pkey);
-      return leave_cmd (ctx, rc);
     }
-
-  rc = parse_keygrip (ctx, line, grip);
-  if (rc)
-    return rc; /* Return immediately as this is already an Assuan error code.*/
-
-  rc = agent_public_key_from_file (ctrl, grip, &s_pkey);
-  if (!rc)
+  else
     {
-      pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, NULL, 0);
-      assert (pkbuflen);
-      pkbuf = xtrymalloc (pkbuflen);
-      if (!pkbuf)
-        rc = gpg_error_from_syserror ();
-      else
+      rc = parse_keygrip (ctx, line, grip);
+      if (rc)
+        goto leave;
+
+      rc = agent_public_key_from_file (ctrl, grip, &s_pkey);
+      if (!rc)
         {
-          gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, pkbuf, pkbuflen);
-          rc = assuan_send_data (ctx, pkbuf, pkbuflen);
-          xfree (pkbuf);
+          pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, NULL, 0);
+          log_assert (pkbuflen);
+          pkbuf = xtrymalloc (pkbuflen);
+          if (!pkbuf)
+            rc = gpg_error_from_syserror ();
+          else
+            {
+              gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, pkbuf, pkbuflen);
+              rc = assuan_send_data (ctx, pkbuf, pkbuflen);
+            }
         }
-      gcry_sexp_release (s_pkey);
     }
 
+ leave:
+  xfree (serialno);
+  xfree (pkbuf);
+  gcry_sexp_release (s_pkey);
   return leave_cmd (ctx, rc);
 }
 

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

Summary of changes:
 agent/command.c | 60 +++++++++++++++++++++++++++++----------------------------
 agent/findkey.c |  8 ++------
 g10/keygen.c    | 11 +++--------
 3 files changed, 36 insertions(+), 43 deletions(-)


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




More information about the Gnupg-commits mailing list