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_4_6-3-g4f1c714


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_4_6-3-g4f1c714
Date: Mon, 14 Sep 2015 13:37:14 +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=4f1c714accd59319dd19833f1f1210710a1dbfb6

The branch, master has been updated
       via  4f1c714accd59319dd19833f1f1210710a1dbfb6 (commit)
       via  e4478fb4a0186f9d59969bf93ed8fa6074729b43 (commit)
       via  a6a05643f0a1a9a5ea431bab65998a7c68b25c03 (commit)
      from  4e7a89e701d43f73b2b1398ad1eda470f7ddb9ee (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 4f1c714accd59319dd19833f1f1210710a1dbfb6
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Sep 14 15:37:10 2015 +0200

    doc update

commit e4478fb4a0186f9d59969bf93ed8fa6074729b43
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Sep 14 15:35:13 2015 +0200

    tests: added check for EXPLICIT encoding of tagged values
    
    This catches the regression introduced by multi-byte tags fix.

commit a6a05643f0a1a9a5ea431bab65998a7c68b25c03
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Sep 14 15:30:53 2015 +0200

    corrected regression in multi-byte tag handling
    
    That is don't treat the explicit tag as part of the inner tag.

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

Summary of changes:
 NEWS                    |    4 ++++
 lib/decoding.c          |   33 +++++++++++++++++++++------------
 tests/Test_encoding.asn |    1 +
 tests/Test_encoding.c   |    8 ++++++++
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index c2a78d6..4d7f477 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 GNU Libtasn1 NEWS                                     -*- outline -*-
 
+* Noteworthy changes in release 4.7 (unreleased) [stable]
+- Fixed regression introduced in the decoding of multi-byte tags
+  fix.
+
 * Noteworthy changes in release 4.6 (released 2015-09-05) [stable]
 - Allow decoding OCTET STRINGs with multi-byte tags.
 - API and ABI changes since last version:
diff --git a/lib/decoding.c b/lib/decoding.c
index 4d2302f..caf1eb4 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -480,10 +480,12 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
   return ASN1_SUCCESS;
 }
 
-
+/* tag_len: the total tag length (explicit+inner)
+ * inner_tag_len: the inner_tag length
+ */
 static int
 _asn1_extract_tag_der (asn1_node node, const unsigned char *der, int der_len,
-                      int *ret_len, unsigned flags)
+                      int *tag_len, int *inner_tag_len, unsigned flags)
 {
   asn1_node p;
   int counter, len2, len3, is_tag_implicit;
@@ -594,7 +596,9 @@ _asn1_extract_tag_der (asn1_node node, const unsigned char 
*der, int der_len,
       unsigned type = type_field (node->type);
       if (type == ASN1_ETYPE_TAG)
        {
-         *ret_len = 0;
+         *tag_len = 0;
+         if (inner_tag_len)
+           *inner_tag_len = 0;
          return ASN1_SUCCESS;
        }
 
@@ -654,7 +658,9 @@ _asn1_extract_tag_der (asn1_node node, const unsigned char 
*der, int der_len,
     }
 
   counter += len2;
-  *ret_len = counter;
+  *tag_len = counter;
+  if (inner_tag_len)
+    *inner_tag_len = len2;
   return ASN1_SUCCESS;
 
 cleanup:
@@ -663,7 +669,7 @@ cleanup:
 
 static int
 extract_tag_der_recursive(asn1_node node, const unsigned char *der, int 
der_len,
-                      int *ret_len, unsigned flags)
+                      int *ret_len, int *inner_len, unsigned flags)
 {
 asn1_node p;
 int ris = ASN1_DER_ERROR;
@@ -673,7 +679,7 @@ int ris = ASN1_DER_ERROR;
       p = node->down;
       while (p)
         {
-          ris = _asn1_extract_tag_der (p, der, der_len, ret_len, flags);
+          ris = _asn1_extract_tag_der (p, der, der_len, ret_len, inner_len, 
flags);
           if (ris == ASN1_SUCCESS)
             break;
           p = p->right;
@@ -683,7 +689,7 @@ int ris = ASN1_DER_ERROR;
       return ris;
     }
   else
-    return _asn1_extract_tag_der (node, der, der_len, ret_len, flags);
+    return _asn1_extract_tag_der (node, der, der_len, ret_len, inner_len, 
flags);
 }
 
 static int
@@ -1014,6 +1020,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
   unsigned long tag;
   int tag_len;
   int indefinite, result, total_len = *max_ider_len, ider_len = *max_ider_len;
+  int inner_tag_len;
   const unsigned char *der = ider;
 
   node = *element;
@@ -1037,6 +1044,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
   while (1)
     {
       tag_len = 0;
+      inner_tag_len = 0;
       ris = ASN1_SUCCESS;
       if (move != UP)
        {
@@ -1074,7 +1082,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
                    {
                      ris =
                          extract_tag_der_recursive (p2, der + counter,
-                                                    ider_len, &len2, flags);
+                                                    ider_len, &len2, NULL, 
flags);
                      if (ris == ASN1_SUCCESS)
                        {
                          p2->type &= ~CONST_NOT_USED;
@@ -1124,7 +1132,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
                {
                  ris =
                      extract_tag_der_recursive (p->down, der + counter,
-                                                ider_len, &len2, flags);
+                                                ider_len, &len2, NULL, flags);
 
                  if (ris == ASN1_SUCCESS)
                    {
@@ -1171,7 +1179,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
          if (ris == ASN1_SUCCESS)
            ris =
              extract_tag_der_recursive (p, der + counter, ider_len, 
-                                        &tag_len, flags);
+                                        &tag_len, &inner_tag_len, flags);
 
          if (ris != ASN1_SUCCESS)
            {
@@ -1289,14 +1297,15 @@ asn1_der_decoding2 (asn1_node *element, const void 
*ider, int *max_ider_len,
              move = RIGHT;
              break;
            case ASN1_ETYPE_OCTET_STRING:
-             if (counter < tag_len)
+             if (counter < inner_tag_len)
                {
                  result = ASN1_DER_ERROR;
                   warn();
                  goto cleanup;
                }
+
              result = get_octet_string (p, der + counter, ider_len, 
-                                        der + counter - tag_len, tag_len,
+                                        der + counter - inner_tag_len, 
inner_tag_len,
                                         &len3, flags);
              if (result != ASN1_SUCCESS)
                {
diff --git a/tests/Test_encoding.asn b/tests/Test_encoding.asn
index de7b93f..040c88f 100644
--- a/tests/Test_encoding.asn
+++ b/tests/Test_encoding.asn
@@ -14,6 +14,7 @@ Koko ::= SEQUENCE {
    a      [1] OCTET STRING,
    b      [10] OCTET STRING,
    c      [100] OCTET STRING,
+   exp    [3] EXPLICIT OCTET STRING OPTIONAL,
    str OCTET STRING
 }
 
diff --git a/tests/Test_encoding.c b/tests/Test_encoding.c
index e693ed7..8e8c702 100644
--- a/tests/Test_encoding.c
+++ b/tests/Test_encoding.c
@@ -133,6 +133,14 @@ main (int argc, char *argv[])
       exit (1);
     }
 
+  result = asn1_write_value (asn1_element, "exp", "string4", 7);
+  if (result != ASN1_SUCCESS)
+    {
+      fprintf (stderr, "asn1_write_value(): str ");
+      asn1_perror (result);
+      exit (1);
+    }
+
   /* Clear the definition structures */
   asn1_delete_structure (&definitions);
 


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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