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_0-8-g0b0de9b


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_4_0-8-g0b0de9b
Date: Wed, 20 Aug 2014 14:20:12 +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=0b0de9bf1a1e7f87a19d2823a8fa7d83ec41532a

The branch, master has been updated
       via  0b0de9bf1a1e7f87a19d2823a8fa7d83ec41532a (commit)
       via  241acd032783cabc7bf1ed8b8b432787dc2cf1c1 (commit)
      from  ad2b479543a0bdfb51a456180cfda8644b4c872d (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 0b0de9bf1a1e7f87a19d2823a8fa7d83ec41532a
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Aug 20 16:19:53 2014 +0200

    corrected check for infinite encoding

commit 241acd032783cabc7bf1ed8b8b432787dc2cf1c1
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Aug 20 16:19:22 2014 +0200

    tests: added additional test for the indefinite any tag

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

Summary of changes:
 lib/decoding.c          |   10 +++++---
 tests/Makefile.am       |    3 +-
 tests/TestIndef3.der    |  Bin 0 -> 660 bytes
 tests/Test_indefinite.c |   49 ++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 52 insertions(+), 10 deletions(-)
 create mode 100644 tests/TestIndef3.der

diff --git a/lib/decoding.c b/lib/decoding.c
index 57da1ff..8b88581 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -904,6 +904,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
   asn1_node ptail = NULL;
   unsigned char class;
   unsigned long tag;
+  int tag_len;
   int indefinite, result, total_len = *max_ider_len, ider_len = *max_ider_len;
   const unsigned char *der = ider;
 
@@ -927,6 +928,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
   p = node;
   while (1)
     {
+      tag_len = 0;
       ris = ASN1_SUCCESS;
       if (move != UP)
        {
@@ -1060,7 +1062,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, &len2);
+             extract_tag_der_recursive (p, der + counter, ider_len, &tag_len);
 
          if (ris != ASN1_SUCCESS)
            {
@@ -1086,8 +1088,8 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
            }
          else
            {
-             DECR_LEN(ider_len, len2);
-             counter += len2;
+             DECR_LEN(ider_len, tag_len);
+             counter += tag_len;
            }
        }
 
@@ -1361,7 +1363,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
              break;
            case ASN1_ETYPE_ANY:
              /* Check indefinite lenth method in an EXPLICIT TAG */
-             if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
+             if ((p->type & CONST_TAG) && tag_len == 2 && (der[counter - 1] == 
0x80))
                indefinite = 1;
              else
                indefinite = 0;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 144b321..639d9c0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,7 @@ LDADD = ../lib/libtasn1.la ../gl/libgnu.la
 
 EXTRA_DIST = Test_parser.asn Test_tree.asn Test_tree_asn1_tab.c        \
        Test_encoding.asn pkix.asn TestIndef.p12 choice.asn 
coding-decoding2.asn \
-       TestIndef2.p12
+       TestIndef2.p12 TestIndef3.der
 
 # For crlf.
 EXTRA_DIST += crlf.cer crl.der
@@ -51,6 +51,7 @@ TESTS_ENVIRONMENT = \
        ASN1CRLDER=$(srcdir)/crl.der \
        ASN1INDEF=$(srcdir)/TestIndef.p12 \
        ASN1INDEF2=$(srcdir)/TestIndef2.p12 \
+       ASN1INDEF3=$(srcdir)/TestIndef3.der \
        ASN1ENCODING=$(srcdir)/Test_encoding.asn \
        THREADSAFETY_FILES=`find $(top_srcdir)/lib -name \*.c` \
        EXEEXT=$(EXEEXT) \
diff --git a/tests/TestIndef3.der b/tests/TestIndef3.der
new file mode 100644
index 0000000..3ad5847
Binary files /dev/null and b/tests/TestIndef3.der differ
diff --git a/tests/Test_indefinite.c b/tests/Test_indefinite.c
index b1a435a..9f08793 100644
--- a/tests/Test_indefinite.c
+++ b/tests/Test_indefinite.c
@@ -49,6 +49,7 @@ main (int argc, char *argv[])
   const char *treefile = getenv ("ASN1PKIX");
   const char *indeffile = getenv ("ASN1INDEF");
   const char *indeffile2 = getenv ("ASN1INDEF2");
+  const char *indeffile3 = getenv ("ASN1INDEF3");
   int verbose = 0;
 
   if (argc > 1)
@@ -61,7 +62,10 @@ main (int argc, char *argv[])
     indeffile = "TestIndef.p12";
 
   if (!indeffile2)
-    indeffile = "TestIndef2.p12";
+    indeffile2 = "TestIndef2.p12";
+
+  if (!indeffile3)
+    indeffile3 = "TestIndef3.der";
 
   if (verbose)
     {
@@ -114,7 +118,7 @@ main (int argc, char *argv[])
   if (result != ASN1_SUCCESS)
     {
       asn1_perror (result);
-      printf ("Cannot decode BER data (size %ld) in %s\n", (long) size, 
indeffile);
+      printf ("Cannot decode BER data (size %ld) in %s: %s\n", (long) size, 
indeffile, errorDescription);
       exit (1);
     }
 
@@ -124,13 +128,13 @@ main (int argc, char *argv[])
   fd = fopen (indeffile2, "rb");
   if (fd == NULL)
     {
-      printf ("Cannot read file %s\n", indeffile);
+      printf ("Cannot read file %s\n", indeffile2);
       exit (1);
     }
   size = fread (buffer, 1, sizeof (buffer), fd);
   if (size <= 0)
     {
-      printf ("Cannot read from file %s\n", indeffile);
+      printf ("Cannot read from file %s\n", indeffile2);
       exit (1);
     }
 
@@ -149,7 +153,42 @@ main (int argc, char *argv[])
   if (result != ASN1_SUCCESS)
     {
       asn1_perror (result);
-      printf ("Cannot decode BER data (size %ld) in %s\n", (long) size, 
indeffile2);
+      printf ("Cannot decode BER data (size %ld) in %s: %s\n", (long) size, 
indeffile2, errorDescription);
+      exit (1);
+    }
+
+  asn1_delete_structure (&asn1_element);
+
+  /* third test */
+  fd = fopen (indeffile3, "rb");
+  if (fd == NULL)
+    {
+      printf ("Cannot read file %s\n", indeffile3);
+      exit (1);
+    }
+  size = fread (buffer, 1, sizeof (buffer), fd);
+  if (size <= 0)
+    {
+      printf ("Cannot read from file %s\n", indeffile3);
+      exit (1);
+    }
+
+  fclose (fd);
+
+  result =
+    asn1_create_element (definitions, "PKIX1.pkcs-12-CertBag", &asn1_element);
+  if (result != ASN1_SUCCESS)
+    {
+      asn1_perror (result);
+      printf ("Cannot create CertBag element\n");
+      exit (1);
+    }
+
+  result = asn1_der_decoding (&asn1_element, buffer, size, errorDescription);
+  if (result != ASN1_SUCCESS)
+    {
+      asn1_perror (result);
+      printf ("Cannot decode DER data (size %ld) in %s: %s\n", (long) size, 
indeffile3, errorDescription);
       exit (1);
     }
 


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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