libtasn1-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU libtasn1 branch, master, updated. libtasn1_3_5-4-g1a1a7a8


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_3_5-4-g1a1a7a8
Date: Sat, 10 May 2014 11:51:36 +0000

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 "GNU libtasn1".

http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=1a1a7a8a27b15e31a408b8cb787e4045eaa57f87

The branch, master has been updated
       via  1a1a7a8a27b15e31a408b8cb787e4045eaa57f87 (commit)
      from  0e6e66769c09e9653e7bbc41e40f4c6a6720305b (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 1a1a7a8a27b15e31a408b8cb787e4045eaa57f87
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat May 10 13:49:32 2014 +0200

    prevent memset() from being optimized out.

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

Summary of changes:
 lib/gstr.h       |   15 +++++++++++++++
 lib/parser_aux.c |    5 +++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/gstr.h b/lib/gstr.h
index 51db059..34e8153 100644
--- a/lib/gstr.h
+++ b/lib/gstr.h
@@ -25,3 +25,18 @@ void _asn1_str_cat (char *dest, size_t dest_tot_size, const 
char *src);
 
 #define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
 #define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
+
+inline static
+void safe_memset(void *data, int c, size_t size)
+{
+       volatile unsigned volatile_zero = 0;
+       volatile char *vdata = (volatile char*)data;
+
+       /* This is based on a nice trick for safe memset,
+        * sent by David Jacobson in the openssl-dev mailing list.
+        */
+
+       do {
+               memset(data, c, size);
+       } while(vdata[volatile_zero] != c);
+}
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index b5f665d..6b34512 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -458,8 +458,9 @@ _asn1_remove_node (asn1_node node, unsigned int flags)
   if (node == NULL)
     return;
 
-  if (flags & ASN1_DELETE_FLAG_ZEROIZE)
-    memset(node->value, 0, node->value_len);
+  if (flags & ASN1_DELETE_FLAG_ZEROIZE && node->value) {
+    safe_memset(node->value, 0, node->value_len);
+  }
 
   if (node->value != NULL && node->value != node->small_value)
     free (node->value);


hooks/post-receive
-- 
GNU libtasn1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]