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_5-9-g50c97c7


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_4_5-9-g50c97c7
Date: Mon, 08 Jun 2015 12:29:03 +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=50c97c70f0386eeb515d8334771d120c02c1a753

The branch, master has been updated
       via  50c97c70f0386eeb515d8334771d120c02c1a753 (commit)
       via  bd50eca8deade9b3bd94189b7f6429d2f1bdf5b1 (commit)
       via  9cb29a180ad5fc0d2d728d162062327b6418ddd5 (commit)
      from  1015d1fd053e4bcc792bb41eca225ef3ccc10fc4 (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 50c97c70f0386eeb515d8334771d120c02c1a753
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Jun 8 14:28:59 2015 +0200

    doc update

commit bd50eca8deade9b3bd94189b7f6429d2f1bdf5b1
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Jun 8 14:27:55 2015 +0200

    tests: added encoding and decoding check with multi-byte tags

commit 9cb29a180ad5fc0d2d728d162062327b6418ddd5
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Jun 8 14:22:44 2015 +0200

    Allow decoding octet strings with multi-byte tags
    
    Report and initial patch by Tomas Petrilak.

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

Summary of changes:
 NEWS                    |    1 +
 lib/decoding.c          |   15 ++++++++++++---
 tests/Test_encoding.asn |    3 +++
 tests/Test_encoding.c   |   24 ++++++++++++++++++++++++
 tests/Test_tree.asn     |    1 -
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 00d97cb..c8c5920 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 GNU Libtasn1 NEWS                                     -*- outline -*-
 
 * Noteworthy changes in release 4.6 (unreleased) [stable]
+- Allow decoding OCTET STRINGs with multi-byte tags.
 - API and ABI changes since last version:
   asn1_get_object_id_der: New function
   asn1_get_time_der: New function
diff --git a/lib/decoding.c b/lib/decoding.c
index bb5f68b..4608cde 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -812,7 +812,8 @@ cleanup:
 }
 
 static int
-_asn1_get_octet_string (asn1_node node, const unsigned char *der, int der_len,
+get_octet_string (asn1_node node, const unsigned char *der, int der_len,
+                        const unsigned char *tag, unsigned tag_len,
                         int *len, unsigned flags)
 {
   int len2, len3, counter, tot_len, indefinite;
@@ -821,7 +822,7 @@ _asn1_get_octet_string (asn1_node node, const unsigned char 
*der, int der_len,
 
   counter = 0;
 
-  if (*(der - 1) & ASN1_CLASS_STRUCTURED)
+  if (tag[0] & ASN1_CLASS_STRUCTURED)
     {
       tot_len = 0;
 
@@ -1298,7 +1299,15 @@ asn1_der_decoding2 (asn1_node *element, const void 
*ider, int *max_ider_len,
              move = RIGHT;
              break;
            case ASN1_ETYPE_OCTET_STRING:
-             result = _asn1_get_octet_string (p, der + counter, ider_len, 
&len3, flags);
+             if (counter < tag_len)
+               {
+                 result = ASN1_DER_ERROR;
+                  warn();
+                 goto cleanup;
+               }
+             result = get_octet_string (p, der + counter, ider_len, 
+                                        der + counter - tag_len, tag_len,
+                                        &len3, flags);
              if (result != ASN1_SUCCESS)
                {
                   warn();
diff --git a/tests/Test_encoding.asn b/tests/Test_encoding.asn
index 99b4b40..de7b93f 100644
--- a/tests/Test_encoding.asn
+++ b/tests/Test_encoding.asn
@@ -11,6 +11,9 @@ BEGIN
 Koko ::= SEQUENCE {
    seqint SEQUENCE OF INTEGER,
    int INTEGER,
+   a      [1] OCTET STRING,
+   b      [10] OCTET STRING,
+   c      [100] OCTET STRING,
    str OCTET STRING
 }
 
diff --git a/tests/Test_encoding.c b/tests/Test_encoding.c
index 7d3266c..e693ed7 100644
--- a/tests/Test_encoding.c
+++ b/tests/Test_encoding.c
@@ -109,6 +109,30 @@ main (int argc, char *argv[])
       exit (1);
     }
 
+  result = asn1_write_value (asn1_element, "a", "string1", 7);
+  if (result != ASN1_SUCCESS)
+    {
+      fprintf (stderr, "asn1_write_value(): str ");
+      asn1_perror (result);
+      exit (1);
+    }
+
+  result = asn1_write_value (asn1_element, "b", "string2", 7);
+  if (result != ASN1_SUCCESS)
+    {
+      fprintf (stderr, "asn1_write_value(): str ");
+      asn1_perror (result);
+      exit (1);
+    }
+
+  result = asn1_write_value (asn1_element, "c", "string3", 7);
+  if (result != ASN1_SUCCESS)
+    {
+      fprintf (stderr, "asn1_write_value(): str ");
+      asn1_perror (result);
+      exit (1);
+    }
+
   /* Clear the definition structures */
   asn1_delete_structure (&definitions);
 
diff --git a/tests/Test_tree.asn b/tests/Test_tree.asn
index da60870..0ad0dc5 100644
--- a/tests/Test_tree.asn
+++ b/tests/Test_tree.asn
@@ -144,7 +144,6 @@ Test3 ::= SEQUENCE{
      b      [1] EXPLICIT GeneralString2
 }
 
-
 GeneralString2 ::= [2] EXPLICIT GeneralString
 
 X520LocalityName ::= CHOICE {


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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