[git] GnuPG - branch, master, updated. gnupg-2.1.13-67-g9c67958

by Justus Winter cvs at cvs.gnupg.org
Tue Jun 28 18:23: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  9c67958c4737b34c60ef2076f57234eec155eb36 (commit)
       via  6cb2be91a7cc8a9b8ec42f3956adbb19347318e3 (commit)
       via  56cebdc30c10eaec179a6911e308074264d876ae (commit)
       via  c57501cc5fa84dbaf560c0fc18853c9540e918af (commit)
       via  c14ef10fc347d966a1efcb5c2000cbf3aaafa905 (commit)
      from  b1e8e0d4b945e077966fb98175191aed056bd957 (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 9c67958c4737b34c60ef2076f57234eec155eb36
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 28 18:13:40 2016 +0200

    gpgscm: Fix memory leaks.
    
    * tests/gpgscm/ffi-private.h (ffi_schemify_name): Fix prototype.
    (ffi_define_function_name): Free schemified name.
    (ffi_define_function): Likewise.
    (ffi_define_constant): Likewise.
    (ffi_define_variable_pointer): Likewise.
    * tests/gpgscm/ffi.c (do_wait_processes): Free arrays.
    (ffi_schemify_name): Fix type.
    * tests/gpgscm/main.c (main): Free 'sc'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/ffi-private.h b/tests/gpgscm/ffi-private.h
index 849d1b7..87f491f 100644
--- a/tests/gpgscm/ffi-private.h
+++ b/tests/gpgscm/ffi-private.h
@@ -84,7 +84,7 @@ int ffi_bool_value (scheme *sc, pointer p);
 #define FFI_RETURN_STRING(SC, X)			\
   FFI_RETURN_POINTER ((SC), mk_string ((SC), (X)))
 
-const char *ffi_schemify_name (const char *s, int macro);
+char *ffi_schemify_name (const char *s, int macro);
 
 void ffi_scheme_eval (scheme *sc, const char *format, ...)
   GPGRT_ATTR_PRINTF (2, 3);
@@ -93,32 +93,46 @@ pointer ffi_sprintf (scheme *sc, const char *format, ...)
 
 #define ffi_define_function_name(SC, NAME, F)				\
   do {									\
+    char *_fname = ffi_schemify_name ("_" #F, 0);                        \
     scheme_define ((SC),						\
 		   (SC)->global_env,					\
-		   mk_symbol ((SC), ffi_schemify_name ("_" #F, 0)),	\
+		   mk_symbol ((SC), _fname),                            \
 		   mk_foreign_func ((SC), (do_##F)));			\
     ffi_scheme_eval ((SC),						\
 		     "(define (%s . a) (ffi-apply \"%s\" %s a))",	\
-		     (NAME), (NAME), ffi_schemify_name ("_" #F, 0));	\
+		     (NAME), (NAME), _fname);                           \
+    free (_fname);                                                      \
   } while (0)
 
-#define ffi_define_function(SC, F)				\
-  ffi_define_function_name ((SC), ffi_schemify_name (#F, 0), F)
+#define ffi_define_function(SC, F)                                      \
+  do {									\
+    char *_name = ffi_schemify_name (#F, 0);                            \
+    ffi_define_function_name ((SC), _name, F);                          \
+    free (_name);                                                       \
+  } while (0)
 
 #define ffi_define_constant(SC, C)					\
-  scheme_define ((SC),							\
-		 (SC)->global_env,					\
-		 mk_symbol ((SC), ffi_schemify_name (#C, 1)),		\
-		 mk_integer ((SC), (C)))
+  do {									\
+    char *_name = ffi_schemify_name (#C, 1);                            \
+    scheme_define ((SC),                                                \
+                   (SC)->global_env,					\
+                   mk_symbol ((SC), _name),                             \
+                   mk_integer ((SC), (C)));                             \
+    free (_name);                                                       \
+  } while (0)
 
 #define ffi_define(SC, SYM, EXP)					\
   scheme_define ((SC), (SC)->global_env, mk_symbol ((SC), (SYM)), EXP)
 
 #define ffi_define_variable_pointer(SC, C, P)				\
-  scheme_define ((SC),							\
-		 (SC)->global_env,					\
-		 mk_symbol ((SC), ffi_schemify_name (#C, 0)),		\
-		 (P))
+  do {									\
+    char *_name = ffi_schemify_name (#C, 0);                            \
+    scheme_define ((SC),                                                \
+                   (SC)->global_env,					\
+                   mk_symbol ((SC), _name),                             \
+                   (P));                                                \
+    free (_name);                                                       \
+  } while (0)
 
 #define ffi_define_variable_integer(SC, C)				\
   ffi_define_variable_pointer ((SC), C, (SC)->vptr->mk_integer ((SC), C))
diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index dcdadaa..acfe1c7 100644
--- a/tests/gpgscm/ffi.c
+++ b/tests/gpgscm/ffi.c
@@ -776,6 +776,9 @@ do_wait_processes (scheme *sc, pointer args)
                                               (long) retcodes[count-1-i]),
                         retcodes_list);
 
+  xfree (names);
+  xfree (pids);
+  xfree (retcodes);
   FFI_RETURN_POINTER (sc, retcodes_list);
 }
 
@@ -1098,7 +1101,7 @@ ffi_list2intv (scheme *sc, pointer list, int **intv, size_t *len)
 }
 
 

-const char *
+char *
 ffi_schemify_name (const char *s, int macro)
 {
   char *n = strdup (s), *p;
diff --git a/tests/gpgscm/main.c b/tests/gpgscm/main.c
index 3414e3d..adb4e33 100644
--- a/tests/gpgscm/main.c
+++ b/tests/gpgscm/main.c
@@ -282,5 +282,6 @@ main (int argc, char **argv)
     }
 
   scheme_deinit (sc);
+  xfree (sc);
   return EXIT_SUCCESS;
 }

commit 6cb2be91a7cc8a9b8ec42f3956adbb19347318e3
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 28 18:10:01 2016 +0200

    gpgscm: Free file names.
    
    * tests/gpgscm/scheme.c (scheme_load_named_file): Free file name.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index aabf400..4c28230 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -4938,6 +4938,11 @@ void scheme_load_named_file(scheme *sc, FILE *fin, const char *filename) {
   if(sc->retcode==0) {
     sc->retcode=sc->nesting!=0;
   }
+
+#if SHOW_ERROR_LINE
+  sc->free(sc->load_stack[0].rep.stdio.filename);
+  sc->load_stack[0].rep.stdio.filename = NULL;
+#endif
 }
 
 void scheme_load_string(scheme *sc, const char *cmd) {

commit 56cebdc30c10eaec179a6911e308074264d876ae
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 28 18:08:01 2016 +0200

    gpgscm: Fix buffer overflow.
    
    * tests/gpgscm/scheme.c (store_string): Avoid writing past allocated
    buffer.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 486194c..aabf400 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -1026,7 +1026,8 @@ static char *store_string(scheme *sc, int len_str, const char *str, char fill) {
           return sc->strbuff;
      }
      if(str!=0) {
-          snprintf(q, len_str+1, "%s", str);
+	  memcpy (q, str, len_str);
+          q[len_str]=0;
      } else {
           memset(q, fill, len_str);
           q[len_str]=0;

commit c57501cc5fa84dbaf560c0fc18853c9540e918af
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 28 18:02:10 2016 +0200

    g10: Fix memory leaks.
    
    * g10/keydb.c (keydb_get_keyblock): Free 'sigstatus' and 'iobuf'.
    * g10/t-keydb-get-keyblock.c: Fix trivial memory leaks.
    * g10/t-keydb.c: Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/g10/keydb.c b/g10/keydb.c
index 17ddd5d..c483bb1 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -1387,11 +1387,8 @@ keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
                 hd->keyblock_cache.pk_no     = pk_no;
                 hd->keyblock_cache.uid_no    = uid_no;
               }
-            else
-              {
-                xfree (sigstatus);
-                iobuf_close (iobuf);
-              }
+            xfree (sigstatus);
+            iobuf_close (iobuf);
           }
       }
       break;
diff --git a/g10/t-keydb-get-keyblock.c b/g10/t-keydb-get-keyblock.c
index c12bab1..cab1448 100644
--- a/g10/t-keydb-get-keyblock.c
+++ b/g10/t-keydb-get-keyblock.c
@@ -59,4 +59,6 @@ do_test (int argc, char *argv[])
 
   rc = keydb_get_keyblock (hd1, &kb1);
   TEST_P ("", ! rc);
+
+  keydb_release (hd1);
 }
diff --git a/g10/t-keydb.c b/g10/t-keydb.c
index f0b7778..3606e2e 100644
--- a/g10/t-keydb.c
+++ b/g10/t-keydb.c
@@ -27,7 +27,7 @@ do_test (int argc, char *argv[])
   int rc;
   KEYDB_HANDLE hd1, hd2;
   KEYDB_SEARCH_DESC desc1, desc2;
-  KBNODE kb1, kb2;
+  KBNODE kb1, kb2, p;
   char *uid1;
   char *uid2;
   char *fname;
@@ -75,17 +75,19 @@ do_test (int argc, char *argv[])
   if (rc)
     ABORT ("Failed to get keyblock for DBFC6AD9");
 
-  while (kb1 && kb1->pkt->pkttype != PKT_USER_ID)
-    kb1 = kb1->next;
-  if (! kb1)
+  p = kb1;
+  while (p && p->pkt->pkttype != PKT_USER_ID)
+    p = p->next;
+  if (! p)
     ABORT ("DBFC6AD9 has no user id packet");
-  uid1 = kb1->pkt->pkt.user_id->name;
+  uid1 = p->pkt->pkt.user_id->name;
 
-  while (kb2 && kb2->pkt->pkttype != PKT_USER_ID)
-    kb2 = kb2->next;
-  if (! kb2)
+  p = kb2;
+  while (p && p->pkt->pkttype != PKT_USER_ID)
+    p = p->next;
+  if (! p)
     ABORT ("1E42B367 has no user id packet");
-  uid2 = kb2->pkt->pkt.user_id->name;
+  uid2 = p->pkt->pkt.user_id->name;
 
   if (verbose)
     {
@@ -94,4 +96,9 @@ do_test (int argc, char *argv[])
     }
 
   TEST_P ("cache consistency", strcmp (uid1, uid2) != 0);
+
+  release_kbnode (kb1);
+  release_kbnode (kb2);
+  keydb_release (hd1);
+  keydb_release (hd2);
 }

commit c14ef10fc347d966a1efcb5c2000cbf3aaafa905
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 28 17:59:17 2016 +0200

    common: Fix memory leaks.
    
    * common/ccparray.c (ccparray_put): Free old array.
    * common/stringhelp.c (do_make_filename): Free 'home'.
    * common/t-convert.c: Fix trivial memory leaks.
    * common/t-iobuf.c: Likewise.
    * common/t-mbox-util.c: Likewise.
    * common/t-name-value.c: Likewise.
    * common/t-stringhelp.c: Likewise.
    * common/t-strlist.c: Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/ccparray.c b/common/ccparray.c
index 490dbf5..d3c2833 100644
--- a/common/ccparray.c
+++ b/common/ccparray.c
@@ -114,6 +114,7 @@ ccparray_put (ccparray_t *cpa, const char *value)
         }
       for (n=0; n < cpa->size; n++)
         newarray[n] = cpa->array[n];
+      xfree (cpa->array);
       cpa->array = newarray;
       cpa->size = newsize;
 
diff --git a/common/stringhelp.c b/common/stringhelp.c
index 0e96c9e..95912e0 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -538,6 +538,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
               home_buffer = xtrymalloc (n);
               if (!home_buffer)
                 {
+                  xfree (home);
                   xfree (name);
                   return NULL;
                 }
@@ -556,6 +557,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
           else
             strcpy (stpcpy (stpcpy (p, home), "/"), name);
 
+          xfree (home);
           xfree (name);
           name = home_buffer;
           /* Let's do a simple compression to catch the most common
diff --git a/common/t-convert.c b/common/t-convert.c
index ad33dff..68824e0 100644
--- a/common/t-convert.c
+++ b/common/t-convert.c
@@ -234,6 +234,7 @@ test_bin2hex (void)
     fail (0);
   else if (strcmp (p, hexstuff))
     fail (0);
+  xfree (p);
 
   p = bin2hex (stuff, (size_t)(-1), NULL);
   if (p)
@@ -266,6 +267,7 @@ test_bin2hexcolon (void)
     fail (0);
   else if (strcmp (p, hexstuff))
     fail (0);
+  xfree (p);
 
   p = bin2hexcolon (stuff, (size_t)(-1), NULL);
   if (p)
diff --git a/common/t-iobuf.c b/common/t-iobuf.c
index 2835df4..0e6f508 100644
--- a/common/t-iobuf.c
+++ b/common/t-iobuf.c
@@ -190,6 +190,8 @@ main (int argc, char *argv[])
 	n ++;
       }
     assert (n == 10 + (strlen (content) - 10) / 2);
+
+    iobuf_close (iobuf);
   }
 
 
@@ -266,6 +268,8 @@ main (int argc, char *argv[])
     /* The string should have been truncated (max_len == 0).  */
     assert (max_len == 0);
     free (buffer);
+
+    iobuf_close (iobuf);
   }
 
   {
@@ -279,10 +283,12 @@ main (int argc, char *argv[])
     int c;
     int n;
     int lastc = 0;
+    struct content_filter_state *state;
 
     iobuf = iobuf_temp_with_content (content, strlen(content));
     rc = iobuf_push_filter (iobuf,
-			    content_filter, content_filter_new (content2));
+			    content_filter,
+                            state=content_filter_new (content2));
     assert (rc == 0);
 
     n = 0;
@@ -309,6 +315,9 @@ main (int argc, char *argv[])
 	    /* printf ("%d: '%c' (%d)\n", n, c, c); */
 	  }
       }
+
+    iobuf_close (iobuf);
+    free (state);
   }
 
   /* Write some data to a temporary filter.  Push a new filter.  The
@@ -346,6 +355,8 @@ main (int argc, char *argv[])
 
     assert (n == strlen (content) + 2 * (strlen (content2) + 1));
     assert (strcmp (buffer, "0123456789aabbcc") == 0);
+
+    iobuf_close (iobuf);
   }
 
   {
@@ -373,6 +384,8 @@ main (int argc, char *argv[])
     assert (n == 2);
     assert (buffer[0] == '3');
     assert (buffer[1] == '7');
+
+    iobuf_close (iobuf);
   }
 
   return 0;
diff --git a/common/t-mbox-util.c b/common/t-mbox-util.c
index dfa4ada..ff48f6c 100644
--- a/common/t-mbox-util.c
+++ b/common/t-mbox-util.c
@@ -87,6 +87,8 @@ run_test (void)
         fail (idx);
       else if (strcmp (mbox, testtbl[idx].mbox))
         fail (idx);
+
+      xfree (mbox);
     }
 }
 
diff --git a/common/t-name-value.c b/common/t-name-value.c
index fc9303b..3b01431 100644
--- a/common/t-name-value.c
+++ b/common/t-name-value.c
@@ -387,19 +387,19 @@ run_modification_tests (void)
   if (private_key_mode)
     {
       err = nvc_set_private_key (pk, key);
-      gcry_sexp_release (key);
       assert (err == 0);
 
       buf = nvc_to_string (pk);
       assert (strcmp (buf, "Key: (hello world)\n") == 0);
       xfree (buf);
-      nvc_release (pk);
     }
   else
     {
       err = nvc_set_private_key (pk, key);
       assert (gpg_err_code (err) == GPG_ERR_MISSING_KEY);
     }
+  gcry_sexp_release (key);
+  nvc_release (pk);
 }
 
 
diff --git a/common/t-stringhelp.c b/common/t-stringhelp.c
index 4f4555e..ccadf02 100644
--- a/common/t-stringhelp.c
+++ b/common/t-stringhelp.c
@@ -223,6 +223,7 @@ test_strconcat (void)
     fail (0);
   else if (errno != EINVAL)
     fail (0);
+  xfree (out);
 
 #if __GNUC__ < 4 /* gcc 4.0 has a sentinel attribute.  */
   out = strconcat (NULL);
@@ -232,6 +233,8 @@ test_strconcat (void)
   out = strconcat (NULL, NULL);
   if (!out || *out)
     fail (1);
+  xfree (out);
+
   out = strconcat ("", NULL);
   if (!out || *out)
     fail (1);
@@ -283,6 +286,7 @@ test_xstrconcat (void)
                    "1", "2", "3", "4", "5", "6", "7", NULL);
   if (!out)
     fail (0);
+  xfree (out);
 
 #if __GNUC__ < 4 /* gcc 4.0 has a sentinel attribute.  */
   out = xstrconcat (NULL);
@@ -292,6 +296,8 @@ test_xstrconcat (void)
   out = xstrconcat (NULL, NULL);
   if (!out)
     fail (1);
+  xfree (out);
+
   out = xstrconcat ("", NULL);
   if (!out || *out)
     fail (1);
@@ -534,6 +540,7 @@ test_strsplit (void)
             fail (tidx * 1000 + i + 1);
           }
 
+      xfree (fields);
       xfree (s2);
     }
 }
diff --git a/common/t-strlist.c b/common/t-strlist.c
index b033905..e49d5a7 100644
--- a/common/t-strlist.c
+++ b/common/t-strlist.c
@@ -67,6 +67,8 @@ test_strlist_rev (void)
     fail (2);
   if (s->next->next->next)
     fail (2);
+
+  free_strlist (s);
 }
 
 

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

Summary of changes:
 common/ccparray.c          |  1 +
 common/stringhelp.c        |  2 ++
 common/t-convert.c         |  2 ++
 common/t-iobuf.c           | 15 ++++++++++++++-
 common/t-mbox-util.c       |  2 ++
 common/t-name-value.c      |  4 ++--
 common/t-stringhelp.c      |  7 +++++++
 common/t-strlist.c         |  2 ++
 g10/keydb.c                |  7 ++-----
 g10/t-keydb-get-keyblock.c |  2 ++
 g10/t-keydb.c              | 25 ++++++++++++++++---------
 tests/gpgscm/ffi-private.h | 40 +++++++++++++++++++++++++++-------------
 tests/gpgscm/ffi.c         |  5 ++++-
 tests/gpgscm/main.c        |  1 +
 tests/gpgscm/scheme.c      |  8 +++++++-
 15 files changed, 91 insertions(+), 32 deletions(-)


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




More information about the Gnupg-commits mailing list