[git] GnuPG - branch, master, updated. gnupg-2.1.17-54-g88e42ef

by Justus Winter cvs at cvs.gnupg.org
Tue Jan 10 16:08:48 CET 2017


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  88e42ef08d65d4d1bc29c6cea48df19ca0d5e2bd (commit)
       via  1f5caf90bfaaaf7b9d8c06c12087aeeae3748032 (commit)
      from  c8cfc62125aceee0ca48aab5c8a9fea1ec1ef652 (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 88e42ef08d65d4d1bc29c6cea48df19ca0d5e2bd
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jan 10 15:50:57 2017 +0100

    tests: Improve gpgconf test.
    
    * tests/openpgp/defs.scm (valgrind): New variable.
    (gpg-config): Fix clearing an option.
    * tests/openpgp/gpgconf.scm: Also toggle 'quiet'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 1895a75..548476b 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -131,6 +131,15 @@
 			  (string-append bin-prefix "/" (basename (caddr t)))
 			  (string-append (getenv "objdir") "/" (caddr t)))))))
 
+;; You can splice VALGRIND into your argument vector to run programs
+;; under valgrind.  For example, to run valgrind on gpg, you may want
+;; to redefine gpg:
+;;
+;; (set! gpg `(, at valgrind , at gpg))
+;;
+(define valgrind
+  '("/usr/bin/valgrind" --leak-check=full --error-exitcode=154))
+
 (define (gpg-conf . args)
   (gpg-conf' "" args))
 (define (gpg-conf' input args)
@@ -149,7 +158,7 @@
      (gpg-conf' (string-append key ":0:" (percent-encode value))
 		`(--change-options ,component)))
    (define (clear)
-     (gpg-conf' (string-append key ":1:")
+     (gpg-conf' (string-append key ":16:")
 		`(--change-options ,component)))))
 
 
diff --git a/tests/openpgp/gpgconf.scm b/tests/openpgp/gpgconf.scm
index cdb6b76..b4cc9cb 100644
--- a/tests/openpgp/gpgconf.scm
+++ b/tests/openpgp/gpgconf.scm
@@ -27,15 +27,25 @@
     ""
     (lambda (progress)
       (do ((i 0 (+ 1 i))) ((> i 12) #t)
-	(opt::update (make-value i))
-	(assert (string=? (make-value i) (list-ref (opt::value) 9)))
+	(let ((value (make-value i)))
+	  (if value
+	      (begin
+		(opt::update value)
+		(assert (string=? value (list-ref (opt::value) 9))))
+	      (begin
+		(opt::clear)
+		(let ((v (opt::value)))
+		  (assert (or (< (length v) 10)
+			      (string=? "" (list-ref v 9))))))))
 	(progress ".")))))
  (lambda (name . rest) name)
- (list "keyserver" "verbose")
+ (list "keyserver" "verbose" "quiet")
  (list (gpg-config 'gpg "keyserver")
-       (gpg-config 'gpg "verbose"))
+       (gpg-config 'gpg "verbose")
+       (gpg-config 'gpg "quiet"))
  (list (lambda (i) (if (even? i) "\"hkp://foo.bar" "\"hkps://bar.baz"))
        (lambda (i) (number->string
 		    ;; gpgconf: argument for option verbose of type 0
 		    ;; (none) must be positive
-		    (+ 1 i)))))
+		    (+ 1 i)))
+       (lambda (i) (if (even? i) #f "1"))))

commit 1f5caf90bfaaaf7b9d8c06c12087aeeae3748032
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jan 10 15:42:27 2017 +0100

    tools: Fix memory leaks and improve error handling.
    
    * tools/gpgconf-comp.c (gc_option_free): New function.
    (gc_components_free): Likewise.
    (gc_components_init): Likewise.
    (retrieve_options_from_program): Use 'xfree', fix memory leak.
    (change_options_program): Improve error handling.
    (gc_component_change_options): Fix memory leaks.
    * tools/gpgconf.c (main): Initialize components.
    * tools/gpgconf.h (gc_components_init): New prototype.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 925f1cf..2dcf075 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1102,6 +1102,35 @@ struct error_line_s
 
 
 

+
+/* Initialization and finalization.  */
+
+static void
+gc_option_free (gc_option_t *o)
+{
+  if (o == NULL || o->name == NULL)
+    return;
+
+  xfree (o->value);
+  gc_option_free (o + 1);
+}
+
+static void
+gc_components_free (void)
+{
+  int i;
+  for (i = 0; i < DIM (gc_component); i++)
+    gc_option_free (gc_component[i].options);
+}
+
+void
+gc_components_init (void)
+{
+  atexit (gc_components_free);
+}
+
+

+
 /* Engine specific support.  */
 static void
 gpg_agent_runtime_change (int killflag)
@@ -2183,7 +2212,7 @@ retrieve_options_from_program (gc_component_t component, gc_backend_t backend)
 	      if (!(option->flags & GC_OPT_FLAG_LIST))
 		{
 		  if (option->value)
-		    free (option->value);
+		    xfree (option->value);
 		  option->value = opt_value;
 		}
 	      else
@@ -2192,10 +2221,9 @@ retrieve_options_from_program (gc_component_t component, gc_backend_t backend)
 		    option->value = opt_value;
 		  else
 		    {
-		      char *opt_val = opt_value;
-
-		      option->value = xasprintf ("%s,%s", option->value,
-						 opt_val);
+		      char *old = option->value;
+		      option->value = xasprintf ("%s,%s", old, opt_value);
+		      xfree (old);
 		      xfree (opt_value);
 		    }
 		}
@@ -2872,7 +2900,12 @@ change_options_program (gc_component_t component, gc_backend_t backend,
   res = link (dest_filename, orig_filename);
 #endif
   if (res < 0 && errno != ENOENT)
-    return -1;
+    {
+      xfree (dest_filename);
+      xfree (src_filename);
+      xfree (orig_filename);
+      return -1;
+    }
   if (res < 0)
     {
       xfree (orig_filename);
@@ -3365,6 +3398,7 @@ gc_component_change_options (int component, estream_t in, estream_t out,
 		}
 	      if (err)
 		break;
+	      xfree (src_filename[i]);
 	      src_filename[i] = NULL;
 	    }
 	}
@@ -3434,10 +3468,17 @@ gc_component_change_options (int component, estream_t in, estream_t out,
 	unlink (backup_filename);
 #endif /* HAVE_W32_SYSTEM */
 	rename (orig_filename[backend], backup_filename);
+	xfree (backup_filename);
       }
 
  leave:
   xfree (line);
+  for (backend = 0; backend < GC_BACKEND_NR; backend++)
+    {
+      xfree (src_filename[backend]);
+      xfree (dest_filename[backend]);
+      xfree (orig_filename[backend]);
+    }
 }
 
 
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index af65424..a1034e6 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -470,6 +470,7 @@ main (int argc, char **argv)
   /* Make sure that our subsystems are ready.  */
   i18n_init();
   init_common_subsystems (&argc, &argv);
+  gc_components_init ();
 
   /* Parse the command line. */
   pargs.argc  = &argc;
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 39d34b6..d6d7627 100644
--- a/tools/gpgconf.h
+++ b/tools/gpgconf.h
@@ -38,6 +38,10 @@ struct
 
 
 /*-- gpgconf-comp.c --*/
+
+/* Initialize the components.  */
+void gc_components_init (void);
+
 /* Percent-Escape special characters.  The string is valid until the
    next invocation of the function.  */
 char *gc_percent_escape (const char *src);

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

Summary of changes:
 tests/openpgp/defs.scm    | 11 +++++++++-
 tests/openpgp/gpgconf.scm | 20 +++++++++++++-----
 tools/gpgconf-comp.c      | 53 +++++++++++++++++++++++++++++++++++++++++------
 tools/gpgconf.c           |  1 +
 tools/gpgconf.h           |  4 ++++
 5 files changed, 77 insertions(+), 12 deletions(-)


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




More information about the Gnupg-commits mailing list