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-34-ge47b2a0


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_3_5-34-ge47b2a0
Date: Sat, 17 May 2014 07:16:49 +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=e47b2a0651ffe1867c844968ade7f6127957bf13

The branch, master has been updated
       via  e47b2a0651ffe1867c844968ade7f6127957bf13 (commit)
       via  e3a8295c5784d36e1a2b1fb0823fda164366e067 (commit)
       via  c29e85f9a9ed0e6780a55891c0af77c0ead137d3 (commit)
      from  cd9876aafe51081022f39407201d83a954750aa5 (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 e47b2a0651ffe1867c844968ade7f6127957bf13
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat May 17 09:11:10 2014 +0200

    Reverted ltostr() changes as the cause a significant delay to the library.
    
    The best approach would be to eliminate the need for ltostr() completely.
    Added LTOSTR_MAX_SIZE, to avoid overflows.

commit e3a8295c5784d36e1a2b1fb0823fda164366e067
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat May 17 09:05:20 2014 +0200

    Revert "simplify ltostr()"
    
    This reverts commit f93acf7f0a3f19692c71fc9022981b6f64ffdbc1.

commit c29e85f9a9ed0e6780a55891c0af77c0ead137d3
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat May 17 09:05:15 2014 +0200

    Revert "made _asn1_ltostr() safer."
    
    This reverts commit 07a5adb87880f3fce80aa12121409bbf652f1b6d.

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

Summary of changes:
 lib/coding.c     |   10 +++++-----
 lib/decoding.c   |   16 ++++++++--------
 lib/element.c    |    4 ++--
 lib/parser_aux.c |   35 +++++++++++++++++++++++++++++++++++
 lib/parser_aux.h |   11 +++--------
 5 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/lib/coding.c b/lib/coding.c
index c560ebf..d6b7cf4 100644
--- a/lib/coding.c
+++ b/lib/coding.c
@@ -594,7 +594,7 @@ _asn1_insert_tag_der (asn1_node node, unsigned char *der, 
int *counter,
 {
   asn1_node p;
   int tag_len, is_tag_implicit;
-  unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
+  unsigned char class, class_implicit = 0, temp[MAX(SIZEOF_UNSIGNED_INT * 3 + 
1, LTOSTR_MAX_SIZE)];
   unsigned long tag_implicit = 0;
   unsigned char tag_der[MAX_TAG_LEN];
 
@@ -631,7 +631,7 @@ _asn1_insert_tag_der (asn1_node node, unsigned char *der, 
int *counter,
                    memcpy (der + *counter, tag_der, tag_len);
                  *counter += tag_len;
 
-                 _asn1_ltostr (*counter, (char *) temp, sizeof(temp));
+                 _asn1_ltostr (*counter, (char *) temp);
                  _asn1_set_name (p, (const char *) temp);
 
                  is_tag_implicit = 0;
@@ -1012,7 +1012,7 @@ asn1_der_coding (asn1_node element, const char *name, 
void *ider, int *len,
                 char *ErrorDescription)
 {
   asn1_node node, p, p2;
-  unsigned char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
+  unsigned char temp[MAX(LTOSTR_MAX_SIZE, SIZEOF_UNSIGNED_LONG_INT * 3 + 1)];
   int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
   int err;
   unsigned char *der = ider;
@@ -1187,7 +1187,7 @@ asn1_der_coding (asn1_node element, const char *name, 
void *ider, int *len,
        case ASN1_ETYPE_SET:
          if (move != UP)
            {
-             _asn1_ltostr (counter, (char *) temp, sizeof(temp));
+             _asn1_ltostr (counter, (char *) temp);
              tlen = _asn1_strlen (temp);
              if (tlen > 0)
                _asn1_set_value (p, temp, tlen + 1);
@@ -1236,7 +1236,7 @@ asn1_der_coding (asn1_node element, const char *name, 
void *ider, int *len,
        case ASN1_ETYPE_SET_OF:
          if (move != UP)
            {
-             _asn1_ltostr (counter, (char *) temp, sizeof(temp));
+             _asn1_ltostr (counter, (char *) temp);
              tlen = _asn1_strlen (temp);
 
              if (tlen > 0)
diff --git a/lib/decoding.c b/lib/decoding.c
index bd96d90..93bc962 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -302,7 +302,7 @@ _asn1_get_objectid_der (const unsigned char *der, int 
der_len, int *ret_len,
 {
   int len_len, len, k;
   int leading;
-  char temp[20];
+  char temp[LTOSTR_MAX_SIZE];
   unsigned long val, val1;
 
   *ret_len = 0;
@@ -320,9 +320,9 @@ _asn1_get_objectid_der (const unsigned char *der, int 
der_len, int *ret_len,
   val1 = der[len_len] / 40;
   val = der[len_len] - val1 * 40;
 
-  _asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp, sizeof(temp)));
+  _asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
   _asn1_str_cat (str, str_size, ".");
-  _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp, sizeof(temp)));
+  _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
 
   val = 0;
   leading = 1;
@@ -344,7 +344,7 @@ _asn1_get_objectid_der (const unsigned char *der, int 
der_len, int *ret_len,
       if (!(der[len_len + k] & 0x80))
        {
          _asn1_str_cat (str, str_size, ".");
-         _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp, sizeof(temp)));
+         _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
          val = 0;
          leading = 1;
        }
@@ -1251,7 +1251,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, 
int ider_len,
 
                  if (len3 > 0)
                    {
-                     _asn1_ltostr (counter + len3, temp, sizeof(temp));
+                     _asn1_ltostr (counter + len3, temp);
                      tlen = strlen (temp);
                      if (tlen > 0)
                        _asn1_set_value (p, temp, tlen + 1);
@@ -1339,7 +1339,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, 
int ider_len,
                    {
                      if (len3 > 0)
                        {       /* definite length method */
-                         _asn1_ltostr (counter + len3, temp, sizeof(temp));
+                         _asn1_ltostr (counter + len3, temp);
                          tlen = strlen (temp);
 
                          if (tlen > 0)
@@ -1952,7 +1952,7 @@ asn1_der_decoding_element (asn1_node * structure, const 
char *elementName,
                      counter += len2;
                      if (len3 > 0)
                        {
-                         _asn1_ltostr (counter + len3, temp, sizeof(temp));
+                         _asn1_ltostr (counter + len3, temp);
                          tlen = strlen (temp);
 
                          if (tlen > 0)
@@ -2035,7 +2035,7 @@ asn1_der_decoding_element (asn1_node * structure, const 
char *elementName,
                      counter += len2;
                      if (len3)
                        {
-                         _asn1_ltostr (counter + len3, temp, sizeof(temp));
+                         _asn1_ltostr (counter + len3, temp);
                          tlen = strlen (temp);
 
                          if (tlen > 0)
diff --git a/lib/element.c b/lib/element.c
index d748f46..359b3ab 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -130,7 +130,7 @@ int
 _asn1_append_sequence_set (asn1_node node)
 {
   asn1_node p, p2;
-  char temp[10];
+  char temp[LTOSTR_MAX_SIZE];
   long n;
 
   if (!node || !(node->down))
@@ -152,7 +152,7 @@ _asn1_append_sequence_set (asn1_node node)
       n = strtol (p->name + 1, NULL, 0);
       n++;
       temp[0] = '?';
-      _asn1_ltostr (n, temp + 1, sizeof(temp)-1);
+      _asn1_ltostr (n, temp + 1);
     }
   _asn1_set_name (p2, temp);
   /*  p2->type |= CONST_OPTION; */
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index 2ca4e61..effedb2 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -531,6 +531,41 @@ _asn1_delete_list_and_nodes (void)
     }
 }
 
+
+char *
+_asn1_ltostr (long v, char *str)
+{
+  long d, r;
+  char temp[LTOSTR_MAX_SIZE];
+  int count, k, start;
+
+  if (v < 0)
+    {
+      str[0] = '-';
+      start = 1;
+      v = -v;
+    }
+  else
+    start = 0;
+
+  count = 0;
+  do
+    {
+      d = v / 10;
+      r = v - d * 10;
+      temp[start + count] = '0' + (char) r;
+      count++;
+      v = d;
+    }
+  while (v);
+
+  for (k = 0; k < count; k++)
+    str[k + start] = temp[start + count - k - 1];
+  str[count + start] = 0;
+  return str;
+}
+
+
 /******************************************************************/
 /* Function : _asn1_change_integer_value                          */
 /* Description: converts into DER coding the value assign to an   */
diff --git a/lib/parser_aux.h b/lib/parser_aux.h
index 8ef105b..1f1aec2 100644
--- a/lib/parser_aux.h
+++ b/lib/parser_aux.h
@@ -25,14 +25,6 @@
 /***************************************/
 /*  Functions used by ASN.1 parser     */
 /***************************************/
-
-inline static char *
-_asn1_ltostr (long v, char *str, size_t str_size)
-{
-  snprintf(str, str_size, "%ld", v);
-  return str;
-}
-
 asn1_node _asn1_add_static_node (unsigned int type);
 
 asn1_node
@@ -60,6 +52,9 @@ void _asn1_delete_list (void);
 
 void _asn1_delete_list_and_nodes (void);
 
+#define LTOSTR_MAX_SIZE 20
+char *_asn1_ltostr (long v, char *str);
+
 asn1_node _asn1_find_up (asn1_node node);
 
 int _asn1_change_integer_value (asn1_node node);


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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