[git] GPGME - branch, master, updated. gpgme-1.11.1-114-g4dd1d0a

by Andre Heinecke cvs at cvs.gnupg.org
Wed Aug 8 14:28:55 CEST 2018


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 "GnuPG Made Easy".

The branch, master has been updated
       via  4dd1d0abd34a382d1cd67cabb737950a39cb3fdc (commit)
       via  fdc07b3ddc2f68e6fcb33703ea41126d0a841290 (commit)
      from  974a95db04f9cdea02867f0246445b4679517ba0 (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 4dd1d0abd34a382d1cd67cabb737950a39cb3fdc
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 8 14:27:24 2018 +0200

    json: Wipe memory in cJSON_Delete
    
    * src/cJSON.c (cJSON_Delete): Wipe memory on deletion.

diff --git a/src/cJSON.c b/src/cJSON.c
index 4da03cc..9e53012 100644
--- a/src/cJSON.c
+++ b/src/cJSON.c
@@ -123,9 +123,15 @@ cJSON_Delete (cJSON * c)
       if (!(c->type & cJSON_IsReference) && c->child)
 	cJSON_Delete (c->child);
       if (!(c->type & cJSON_IsReference) && c->valuestring)
-	xfree (c->valuestring);
+        {
+          wipememory (c->valuestring, strlen (c->valuestring));
+          xfree (c->valuestring);
+        }
       if (c->string)
-	xfree (c->string);
+        {
+          wipememory (c->string, strlen (c->string));
+          xfree (c->string);
+        }
       xfree (c);
       c = next;
     }

commit fdc07b3ddc2f68e6fcb33703ea41126d0a841290
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 8 14:25:28 2018 +0200

    json: Only use calloc instead of malloc
    
    * src/cJSON.c, src/gpgme-json.c (CALLOC_ONLY): New define
    to change xmalloc / xtrymalloc to use calloc.
    
    --
    Some people consider malloc dangerous as it might allow an
    information leak.

diff --git a/src/cJSON.c b/src/cJSON.c
index eea1adf..4da03cc 100644
--- a/src/cJSON.c
+++ b/src/cJSON.c
@@ -45,20 +45,42 @@
 #include <ctype.h>
 #include <errno.h>
 
+#include <gpg-error.h>
+
 #include "cJSON.h"
 
+/* Only use calloc. */
+#define CALLOC_ONLY 1
+
+/* To avoid that a compiler optimizes certain memset calls away, these
+   macros may be used instead. */
+#define wipememory2(_ptr,_set,_len) do { \
+        volatile char *_vptr=(volatile char *)(_ptr); \
+        size_t _vlen=(_len); \
+        while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
+    } while(0)
+#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
+
 /* We use malloc function wrappers from gpgrt (aka libgpg-error).  */
 #if GPGRT_VERSION_NUMBER >= 0x011c00 /* 1.28 */
 # include <gpgrt.h>
-# define xtrymalloc(a)   gpgrt_malloc ((a))
 # define xtrycalloc(a,b) gpgrt_calloc ((a), (b))
 # define xtrystrdup(a)   gpgrt_strdup ((a))
 # define xfree(a)        gpgrt_free ((a))
+# if CALLOC_ONLY
+#  define xtrymalloc(a)  gpgrt_calloc (1, (a))
+# else
+#  define xtrymalloc(a)  gpgrt_malloc ((a))
+# endif
 #else /* Without gpgrt (aka libgpg-error).  */
-# define xtrymalloc(a)   malloc ((a))
 # define xtrycalloc(a,b) calloc ((a), (b))
 # define xtrystrdup(a)   strdup ((a))
 # define xfree(a)        free ((a))
+# if CALLOC_ONLY
+#  define xtrymalloc(a)  calloc (1, (a))
+# else
+#  define xtrymalloc(a)  malloc ((a))
+# endif
 #endif
 
 
diff --git a/src/gpgme-json.c b/src/gpgme-json.c
index 9cae944..5a9b9cf 100644
--- a/src/gpgme-json.c
+++ b/src/gpgme-json.c
@@ -87,13 +87,7 @@ static struct
  * Helper functions and macros
  */
 
-#define xtrymalloc(a)  gpgrt_malloc ((a))
 #define xtrystrdup(a)  gpgrt_strdup ((a))
-#define xmalloc(a) ({                           \
-      void *_r = gpgrt_malloc ((a));            \
-      if (!_r)                                  \
-        xoutofcore ("malloc");                  \
-      _r; })
 #define xcalloc(a,b) ({                         \
       void *_r = gpgrt_calloc ((a), (b));       \
       if (!_r)                                  \
@@ -111,6 +105,21 @@ static struct
       _r; })
 #define xfree(a) gpgrt_free ((a))
 
+/* Only use calloc. */
+#define CALLOC_ONLY 1
+
+#if CALLOC_ONLY
+#define xtrymalloc(a)  gpgrt_calloc (1, (a))
+#define xmalloc(a) xcalloc(1, (a))
+#else
+#define xtrymalloc(a)  gpgrt_malloc ((a))
+#define xmalloc(a) ({                           \
+      void *_r = gpgrt_malloc ((a));            \
+      if (!_r)                                  \
+        xoutofcore ("malloc");                  \
+      _r; })
+#endif
+
 #define spacep(p)   (*(p) == ' ' || *(p) == '\t')
 
 #ifndef HAVE_STPCPY

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

Summary of changes:
 src/cJSON.c      | 36 ++++++++++++++++++++++++++++++++----
 src/gpgme-json.c | 21 +++++++++++++++------
 2 files changed, 47 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list