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_3-6-gc5a9cfa


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_3_3-6-gc5a9cfa
Date: Wed, 13 Nov 2013 12:56:44 +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=c5a9cfaf1bc008a2b4b7bbd544a8f3ab3d62d953

The branch, master has been updated
       via  c5a9cfaf1bc008a2b4b7bbd544a8f3ab3d62d953 (commit)
      from  ef90ba764f1032f097ae77443651656b3d712ebf (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 c5a9cfaf1bc008a2b4b7bbd544a8f3ab3d62d953
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Nov 13 13:55:14 2013 +0100

    Added asn1_delete_structure2().
    
    The new function accepts additional flags to be used during 
deinitialization.
    For the moment the only available flag is ASN1_DELETE_FLAG_ZEROIZE which 
zeroizes
    all values in the structure prior to deinitialization.

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

Summary of changes:
 NEWS             |    2 ++
 lib/libtasn1.h   |    8 ++++++++
 lib/parser_aux.c |   10 +++++++---
 lib/parser_aux.h |    2 +-
 lib/structure.c  |   23 ++++++++++++++++++++---
 5 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index f7fc31a..99b7105 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 GNU Libtasn1 NEWS                                     -*- outline -*-
 
 * Noteworthy changes in release 3.4 (unreleased) [stable]
+- Added asn1_delete_structure2() which allows zeroizing the contents
+  of all values in the structure prior to deinitialization.
 
 * Noteworthy changes in release 3.3 (released 2013-03-23) [stable]
 - More precise overflow checks using gnulib's intprops module.
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
index a2da884..f29e6a4 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -168,6 +168,12 @@ extern "C"
 #define ASN1_ETYPE_UTC_TIME       36
 #define ASN1_ETYPE_GENERALIZED_TIME 37
 
+/* Flags used by asn1_delete_structure2() */
+
+/* makes sure the values are zeroized prior to deinitialization */
+#define ASN1_DELETE_FLAG_ZEROIZE 1
+
+
   struct asn1_data_node_st
   {
     const char *name;          /* Node name */
@@ -214,6 +220,8 @@ extern "C"
 
   extern ASN1_API int asn1_delete_structure (asn1_node * structure);
 
+  extern ASN1_API int asn1_delete_structure2 (asn1_node * structure, unsigned 
int flags);
+
   extern ASN1_API int
     asn1_delete_element (asn1_node structure, const char *element_name);
 
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index 34bf1e7..fccfed5 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -450,12 +450,16 @@ _asn1_get_last_right (asn1_node node)
 /*              element (not the elements pointed by it).         */
 /* Parameters:                                                    */
 /*   node: NODE_ASN element pointer.                              */
+/*   flags: ASN1_DELETE_FLAG_*                                    */
 /******************************************************************/
 void
-_asn1_remove_node (asn1_node node)
+_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 (node->value != NULL && node->value != node->small_value)
     free (node->value);
@@ -517,7 +521,7 @@ _asn1_delete_list_and_nodes (void)
     {
       listElement = firstElement;
       firstElement = firstElement->next;
-      _asn1_remove_node (listElement->node);
+      _asn1_remove_node (listElement->node, 0);
       free (listElement);
     }
 }
@@ -672,7 +676,7 @@ _asn1_expand_object_id (asn1_node node)
                          || !(p3->type & CONST_ASSIGN))
                        return ASN1_ELEMENT_NOT_FOUND;
                      _asn1_set_down (p, p2->right);
-                     _asn1_remove_node (p2);
+                     _asn1_remove_node (p2, 0);
                      p2 = p;
                      p4 = p3->down;
                      while (p4)
diff --git a/lib/parser_aux.h b/lib/parser_aux.h
index 24663eb..5fd4e64 100644
--- a/lib/parser_aux.h
+++ b/lib/parser_aux.h
@@ -48,7 +48,7 @@ asn1_node _asn1_set_right (asn1_node node, asn1_node right);
 
 asn1_node _asn1_get_last_right (asn1_node node);
 
-void _asn1_remove_node (asn1_node node);
+void _asn1_remove_node (asn1_node node, unsigned int flags);
 
 void _asn1_delete_list (void);
 
diff --git a/lib/structure.c b/lib/structure.c
index 22f1037..611ed94 100644
--- a/lib/structure.c
+++ b/lib/structure.c
@@ -287,6 +287,23 @@ asn1_array2tree (const asn1_static_node * array, asn1_node 
* definitions,
 int
 asn1_delete_structure (asn1_node * structure)
 {
+  return asn1_delete_structure2(structure, 0);
+}
+
+/**
+ * asn1_delete_structure2:
+ * @structure: pointer to the structure that you want to delete.
+ * @flags: additional flags (see %ASN1_DELETE_FLAG)
+ *
+ * Deletes the structure address@hidden  At the end, address@hidden is set
+ * to NULL.
+ *
+ * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
+ *   address@hidden was NULL.
+ **/
+int
+asn1_delete_structure2 (asn1_node * structure, unsigned int flags)
+{
   asn1_node p, p2, p3;
 
   if (*structure == NULL)
@@ -306,7 +323,7 @@ asn1_delete_structure (asn1_node * structure)
            {
              p3 = _asn1_find_up (p);
              _asn1_set_down (p3, p2);
-             _asn1_remove_node (p);
+             _asn1_remove_node (p, flags);
              p = p3;
            }
          else
@@ -325,7 +342,7 @@ asn1_delete_structure (asn1_node * structure)
                }
              else
                _asn1_set_right (p3, p2);
-             _asn1_remove_node (p);
+             _asn1_remove_node (p, flags);
              p = NULL;
            }
        }
@@ -598,7 +615,7 @@ _asn1_expand_identifier (asn1_node * node, asn1_node root)
 
              if (p == *node)
                *node = p2;
-             _asn1_remove_node (p);
+             _asn1_remove_node (p, 0);
              p = p2;
              move = DOWN;
              continue;


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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