[git] GnuPG - branch, master, updated. gnupg-2.1.20-7-g32b75fb

by Justus Winter cvs at cvs.gnupg.org
Tue Apr 4 18:55:22 CEST 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  32b75fb7743f35936d7014fce33c90ba97dfa374 (commit)
       via  6261611d3786f19fd84ccc79f45a89cadac518e8 (commit)
       via  a80d4a9b50ad47eae1f8c740dd73804311e38783 (commit)
       via  d858096c99705ccf2e115475f81c4cf88edbeebf (commit)
      from  685438bf6fe78c38919031a6ae35576ece7f47cf (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 32b75fb7743f35936d7014fce33c90ba97dfa374
Author: Justus Winter <justus at g10code.com>
Date:   Tue Apr 4 14:32:04 2017 +0200

    tests: Fix setup of ephemeral home directories.
    
    * tests/openpgp/defs.scm (with-ephemeral-home-directory): Create
    configuration files when we enter the context.
    * tests/openpgp/setup.scm: Do not use an ephemeral home directory.
    Tests should always use the cwd.
    * tests/gpgsm/setup.scm: Likewise.
    * tests/gpgsm/export.scm: Add explicit constructor function.
    * tests/openpgp/decrypt-session-key.scm: Likewise.
    * tests/openpgp/decrypt-unwrap-verify.scm: Likewise.
    --
    
    Previously, ephemeral homedirectories lacked a configuration, hence
    GnuPG tried to start backend daemons using their installed locations.
    Fix this by explicitly creating a suitable configuration.
    
    GnuPG-bug-id: 3047
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgsm/export.scm b/tests/gpgsm/export.scm
index 1ee91e4..47fb06e 100644
--- a/tests/gpgsm/export.scm
+++ b/tests/gpgsm/export.scm
@@ -25,7 +25,7 @@
  (lambda (cert)
    (lettmp (exported)
      (call-check `(, at gpgsm --output ,exported --export ,cert::uid::CN))
-     (with-ephemeral-home-directory
+     (with-ephemeral-home-directory setup-gpgsm-environment
       (call-check `(, at gpgsm --import ,exported))
       (assert (sm-have-public-key? cert)))))
  (lambda (cert) cert::uid::CN)
diff --git a/tests/gpgsm/setup.scm b/tests/gpgsm/setup.scm
index 91821a0..aa1ab41 100644
--- a/tests/gpgsm/setup.scm
+++ b/tests/gpgsm/setup.scm
@@ -23,8 +23,6 @@
 (unless (and tarball (not (null? tarball)))
 	(error "Usage: setup.scm --create-tarball <file> ..."))
 
-(with-ephemeral-home-directory
- (chdir (getenv "GNUPGHOME"))
- (create-gpgsmhome)
- (stop-agent)
- (call-check `(,(tool 'gpgtar) --create --output ,(car tarball) ".")))
+(setenv "GNUPGHOME" (getcwd) #t)
+(create-gpgsmhome)
+(call-check `(,(tool 'gpgtar) --create --output ,(car tarball) "."))
diff --git a/tests/openpgp/decrypt-session-key.scm b/tests/openpgp/decrypt-session-key.scm
index 771b53d..989ce30 100755
--- a/tests/openpgp/decrypt-session-key.scm
+++ b/tests/openpgp/decrypt-session-key.scm
@@ -37,7 +37,7 @@
  (lambda (name)
    (let* ((source (in-srcdir (string-append name ".asc")))
 	  (key (get-session-key source)))
-     (with-ephemeral-home-directory
+     (with-ephemeral-home-directory setup-environment
       (tr:do
        (tr:open source)
        (tr:gpg "" `(--yes --decrypt --override-session-key ,key))
diff --git a/tests/openpgp/decrypt-unwrap-verify.scm b/tests/openpgp/decrypt-unwrap-verify.scm
index 97a72e4..ef9a99a 100755
--- a/tests/openpgp/decrypt-unwrap-verify.scm
+++ b/tests/openpgp/decrypt-unwrap-verify.scm
@@ -35,7 +35,7 @@
 
        ;; Then, verify the signature with a clean working directory
        ;; containing only Steve's public key.
-       (with-ephemeral-home-directory
+       (with-ephemeral-home-directory setup-environment
 	(call-check `(, at gpg --import ,steve's-key))
 	(call-check `(, at gpg --verify ,unwrapped)))))
   '("encsig-2-keys-3" "encsig-2-keys-4")))
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index e8d06c0..4271ba0 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -289,14 +289,18 @@
 
 ;; Evaluate a sequence of expressions with an ephemeral home
 ;; directory.
-(define-macro (with-ephemeral-home-directory . expressions)
+(define-macro (with-ephemeral-home-directory setup-fn . expressions)
   (let ((original-home-directory (gensym))
-	(ephemeral-home-directory (gensym)))
+	(ephemeral-home-directory (gensym))
+	(setup (gensym)))
     `(let ((,original-home-directory (getenv "GNUPGHOME"))
-	   (,ephemeral-home-directory (mkdtemp)))
+	   (,ephemeral-home-directory (mkdtemp))
+	   (,setup (delay (,setup-fn))))
        (finally (unlink-recursively ,ephemeral-home-directory)
 	 (dynamic-wind
-	     (lambda () (setenv "GNUPGHOME" ,ephemeral-home-directory #t))
+	     (lambda ()
+	       (force ,setup)
+	       (setenv "GNUPGHOME" ,ephemeral-home-directory #t))
 	     (lambda () , at expressions)
 	     (lambda () (setenv "GNUPGHOME" ,original-home-directory #t)))))))
 
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index 4b3bfcb..a7d14e7 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -40,10 +40,9 @@
        '(gpgconf gpg gpg-agent scdaemon gpgsm dirmngr gpg-connect-agent
 		 gpg-preset-passphrase gpgtar pinentry)))
 
-(with-ephemeral-home-directory
- (chdir (getenv "GNUPGHOME"))
- (create-gpghome)
- (start-agent)
- (create-legacy-gpghome)
- (stop-agent)
- (call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) ".")))
+(setenv "GNUPGHOME" (getcwd) #t)
+(create-gpghome)
+(start-agent)
+(create-legacy-gpghome)
+(stop-agent)
+(call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) "."))

commit 6261611d3786f19fd84ccc79f45a89cadac518e8
Author: Justus Winter <justus at g10code.com>
Date:   Tue Apr 4 17:36:45 2017 +0200

    gpgscm: Fix copying values.
    
    * tests/gpgscm/scheme.c (copy_value): New function.
    (mk_tagged_value): Use new function.
    (opexe_4): Likewise for OP_SAVE_FORCED.
    --
    
    Occasionally, we need to copy a value from one location in the storage
    to another.  Scheme objects are fine.  Some primitive objects,
    however, require finalization, usually to free resources.
    
    For these values, we either make a copy or acquire a reference.
    
    Fixes e.g. a double free if a delayed expression evaluating to a
    string is forced.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 736486f..51fdef0 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -624,6 +624,56 @@ static long binary_decode(const char *s) {
 
 

 
+/*
+ * Copying values.
+ *
+ * Occasionally, we need to copy a value from one location in the
+ * storage to another.  Scheme objects are fine.  Some primitive
+ * objects, however, require finalization, usually to free resources.
+ *
+ * For these values, we either make a copy or acquire a reference.
+ */
+
+/*
+ * Copy SRC to DST.
+ *
+ * Copies the representation of SRC to DST.  This makes SRC
+ * indistinguishable from DST from the perspective of a Scheme
+ * expression modulo the fact that they reside at a different location
+ * in the store.
+ *
+ * Conditions:
+ *
+ *     - SRC must not be a vector.
+ *     - Caller must ensure that any resources associated with the
+ *       value currently stored in DST is accounted for.
+ */
+static void
+copy_value(scheme *sc, pointer dst, pointer src)
+{
+  memcpy(dst, src, sizeof *src);
+
+  /* We may need to make a copy or acquire a reference.  */
+  if (typeflag(dst) & T_FINALIZE)
+    switch (type(dst)) {
+    case T_STRING:
+      strvalue(dst) = store_string(sc, strlength(dst), strvalue(dst), 0);
+      break;
+    case T_PORT:
+      /* XXX acquire reference */
+      assert (!"implemented");
+      break;
+    case T_FOREIGN_OBJECT:
+      /* XXX acquire reference */
+      assert (!"implemented");
+      break;
+     case T_VECTOR:
+      assert (!"vectors cannot be copied");
+    }
+}
+
+

+
 /* Tags are like property lists, but can be attached to arbitrary
  * values.  */
 
@@ -640,7 +690,7 @@ mk_tagged_value(scheme *sc, pointer v, pointer tag_car, pointer tag_cdr)
   if (r == sc->sink)
     return sc->sink;
 
-  memcpy(r, v, sizeof *v);
+  copy_value(sc, r, v);
   typeflag(r) |= T_TAGGED;
 
   t = r + 1;
@@ -4603,7 +4653,7 @@ static pointer opexe_4(scheme *sc, enum scheme_opcodes op) {
           }
 
      CASE(OP_SAVE_FORCED):     /* Save forced value replacing promise */
-          memcpy(sc->code,sc->value,sizeof(struct cell));
+	  copy_value(sc, sc->code, sc->value);
           s_return(sc,sc->value);
 
      CASE(OP_WRITE):      /* write */

commit a80d4a9b50ad47eae1f8c740dd73804311e38783
Author: Justus Winter <justus at g10code.com>
Date:   Tue Apr 4 17:38:50 2017 +0200

    gpgscm: Simplify get-output-string operation.
    
    * tests/gpgscm/scheme.c (opexe_4): Simplify 'get-output-string'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 3c7afa3..736486f 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -4811,20 +4811,12 @@ static pointer opexe_4(scheme *sc, enum scheme_opcodes op) {
           port *p;
 
           if ((p=car(sc->args)->_object._port)->kind&port_string) {
-               off_t size;
-               char *str;
-
-               size=p->rep.string.curr-p->rep.string.start+1;
-               str=sc->malloc(size);
-               if(str != NULL) {
-                    pointer s;
-
-                    memcpy(str,p->rep.string.start,size-1);
-                    str[size-1]='\0';
-                    s=mk_string(sc,str);
-                    sc->free(str);
-                    s_return(sc,s);
-               }
+	       gc_disable(sc, 1);
+	       s_return_enable_gc(
+		    sc,
+		    mk_counted_string(sc,
+				      p->rep.string.start,
+				      p->rep.string.curr - p->rep.string.start));
           }
           s_return(sc,sc->F);
      }

commit d858096c99705ccf2e115475f81c4cf88edbeebf
Author: Justus Winter <justus at g10code.com>
Date:   Tue Apr 4 14:28:45 2017 +0200

    gpgscm: Simplify substring operation.
    
    * tests/gpgscm/scheme.c (opexe_2): Simplify 'substring'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index fbc562d..3c7afa3 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -4355,7 +4355,6 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
           char *str;
           int index0;
           int index1;
-          int len;
 
           str=strvalue(car(sc->args));
 
@@ -4374,13 +4373,8 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
                index1=strlength(car(sc->args));
           }
 
-          len=index1-index0;
 	  gc_disable(sc, 1);
-          x=mk_empty_string(sc,len,' ');
-          memcpy(strvalue(x),str+index0,len);
-          strvalue(x)[len]=0;
-
-          s_return_enable_gc(sc, x);
+          s_return_enable_gc(sc, mk_counted_string(sc, str + index0, index1 - index0));
      }
 
      CASE(OP_VECTOR): {   /* vector */

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

Summary of changes:
 tests/gpgscm/scheme.c                   | 82 ++++++++++++++++++++++++---------
 tests/gpgsm/export.scm                  |  2 +-
 tests/gpgsm/setup.scm                   |  8 ++--
 tests/openpgp/decrypt-session-key.scm   |  2 +-
 tests/openpgp/decrypt-unwrap-verify.scm |  2 +-
 tests/openpgp/defs.scm                  | 12 +++--
 tests/openpgp/setup.scm                 | 13 +++---
 7 files changed, 79 insertions(+), 42 deletions(-)


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




More information about the Gnupg-commits mailing list