add self test
authorFabio Fiorina <fiorinaf@gnutls.org>
Wed, 8 Sep 2004 19:45:46 +0000 (19:45 +0000)
committerFabio Fiorina <fiorinaf@gnutls.org>
Wed, 8 Sep 2004 19:45:46 +0000 (19:45 +0000)
NEWS
configure.in
lib/decoding.c
lib/int.h
lib/libtasn1.h
tests/Makefile.am
tests/Test_parser.c
tests/Test_tree.c

diff --git a/NEWS b/NEWS
index f5f7128..1b5e73b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+Version 0.2.11
+- Added the self test with "make check" target
+- Added management of ANY type with null length
 Version 0.2.10
 - Added scripts to assist in libtasn1 version detection
   from configure scripts.
index fd7d774..01b5a57 100644 (file)
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name])
 dnl libtasn1 Version
 ASN1_MAJOR_VERSION=0
 ASN1_MINOR_VERSION=2
-ASN1_MICRO_VERSION=10
+ASN1_MICRO_VERSION=11
 ASN1_VERSION=$ASN1_MAJOR_VERSION.$ASN1_MINOR_VERSION.$ASN1_MICRO_VERSION
 
 AC_DEFINE_UNQUOTED(ASN1_VERSION, "$ASN1_VERSION", [version of libtasn1])
index de3573a..b99da9f 100644 (file)
@@ -719,7 +719,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
        counter+=len3+len2;
        move=RIGHT;
        break;
-      case TYPE_SEQUENCE:  case TYPE_SET:;
+      case TYPE_SEQUENCE:  case TYPE_SET:
        if(move==UP){
          len2=strtol(p->value,NULL,10);
          _asn1_set_value(p,NULL,0);
@@ -815,12 +815,6 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
        move=RIGHT;
        break;
       case TYPE_ANY:
-       /* Check indefinite lenth method in a EXPLICIT TAG */
-       if((p->type&CONST_TAG) && (der[counter-1]==0x80))
-         indefinite=1;
-       else
-         indefinite=0;
-
        tag=_asn1_get_tag_der(der+counter,&class,&len2);
        len4=_asn1_get_length_der(der+counter+len2,&len3);
        
@@ -839,6 +833,12 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
          counter+=len2+len3;
        }
        else{ /* indefinite length */
+         /* Check indefinite lenth method in a EXPLICIT TAG */
+         if((p->type&CONST_TAG) && (der[counter-1]==0x80))
+           indefinite=1;
+         else
+           indefinite=0;
+
          len2=len-counter;
          ris=_asn1_get_indefinite_length_string(der+counter,&len2);
          if(ris != ASN1_SUCCESS){
@@ -856,17 +856,17 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
          _asn1_set_value(p,temp2,len4);
          _asn1_afree(temp2);
          counter+=len2;
-       }
 
-       /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
-          a indefinite length method. */
-       if(indefinite){
-         if(!der[counter] && !der[counter+1]){ 
-           counter+=2;
-         }
-         else{
-           asn1_delete_structure(element);
-           return ASN1_DER_ERROR;
+         /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
+            a indefinite length method. */
+         if(indefinite){
+           if(!der[counter] && !der[counter+1]){ 
+             counter+=2;
+           }
+           else{
+             asn1_delete_structure(element);
+             return ASN1_DER_ERROR;
+           }
          }
        }
        move=RIGHT;
@@ -1313,12 +1313,6 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
        
        break;
       case TYPE_ANY:
-       /* Check indefinite lenth method in a EXPLICIT TAG */
-       if((p->type&CONST_TAG) && (der[counter-1]==0x80))
-         indefinite=1;
-       else
-         indefinite=0;
-
        tag=_asn1_get_tag_der(der+counter,&class,&len2);
        len4=_asn1_get_length_der(der+counter+len2,&len3);
        
@@ -1341,6 +1335,12 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
          counter+=len2+len3;
        }
        else{ /* indefinite length */
+         /* Check indefinite lenth method in a EXPLICIT TAG */
+         if((p->type&CONST_TAG) && (der[counter-1]==0x80))
+           indefinite=1;
+         else
+           indefinite=0;
+
          len2=len-counter;
          ris=_asn1_get_indefinite_length_string(der+counter,&len2);
          if(ris != ASN1_SUCCESS){
@@ -1364,17 +1364,17 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
          }
 
          counter+=len2;
-       }
 
-       /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
-          a indefinite length method. */
-       if(indefinite){
-         if(!der[counter] && !der[counter+1]){ 
-           counter+=2;
-         }
-         else{
-           asn1_delete_structure(structure);
-           return ASN1_DER_ERROR;
+         /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
+            a indefinite length method. */
+         if(indefinite){
+           if(!der[counter] && !der[counter+1]){ 
+             counter+=2;
+           }
+           else{
+             asn1_delete_structure(structure);
+             return ASN1_DER_ERROR;
+           }
          }
        }
        move=RIGHT;
@@ -1683,12 +1683,6 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len,
        move=RIGHT;
        break;
       case TYPE_ANY:
-       /* Check indefinite lenth method in a EXPLICIT TAG */
-       if((p->type&CONST_TAG) && (der[counter-1]==0x80))
-         indefinite=1;
-       else
-         indefinite=0;
-
        tag=_asn1_get_tag_der(der+counter,&class,&len2);
        len4=_asn1_get_length_der(der+counter+len2,&len3);
        
@@ -1696,20 +1690,26 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len,
          counter+=len2+len4+len3;
        }
        else{ /* indefinite length */
+         /* Check indefinite lenth method in a EXPLICIT TAG */
+         if((p->type&CONST_TAG) && (der[counter-1]==0x80))
+           indefinite=1;
+         else
+           indefinite=0;
+         
          len2=len-counter;
          ris=_asn1_get_indefinite_length_string(der+counter,&len2);
          if(ris != ASN1_SUCCESS)
            return ris;
          counter+=len2;
-       }
 
-       /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
-          a indefinite length method. */
-       if(indefinite){
-         if(!der[counter] && !der[counter+1])
-           counter+=2;
-         else
-           return ASN1_DER_ERROR;
+         /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
+            a indefinite length method. */
+         if(indefinite){
+           if(!der[counter] && !der[counter+1])
+             counter+=2;
+           else
+             return ASN1_DER_ERROR;
+         }
        }
        move=RIGHT;
        break;
index eae5141..04297b7 100644 (file)
--- a/lib/int.h
+++ b/lib/int.h
@@ -32,7 +32,7 @@
 
 #include <mem.h>
 
-#define LIBTASN1_VERSION "0.2.10"
+#define LIBTASN1_VERSION "0.2.11"
 
 #define MAX32 4294967295
 #define MAX24 16777215
index 7efad81..8d460b1 100644 (file)
@@ -28,7 +28,7 @@
 extern "C" {
 #endif
 
-#define LIBTASN1_VERSION "0.2.10"
+#define LIBTASN1_VERSION "0.2.11"
 
 #include <sys/types.h>
 #include <time.h>
index 768163e..e79017b 100644 (file)
@@ -2,7 +2,8 @@ INCLUDES = -I../lib
 
 EXTRA_DIST = Test_parser.asn Test_tree.asn Test_tree_asn1_tab.c
 
-noinst_PROGRAMS = Test_parser Test_tree
+TESTS = Test_parser Test_tree
+check_PROGRAMS = $(TESTS)
 Test_parser_SOURCES = Test_parser.c  
 Test_parser_LDADD = ../lib/libtasn1.la
 
index 7a0688e..95fbbbf 100644 (file)
@@ -197,6 +197,9 @@ main(int argc,char *argv[])
   printf("Total tests : %d\n",testCounter);
   printf("Total errors: %d\n",errorCounter);
 
+  if(errorCounter > 0)
+    return 1;
+
   exit(0);
 }
 
index d6c5af2..358f22d 100644 (file)
@@ -420,7 +420,7 @@ main(int argc,char *argv[])
   printf(    "/****************************************/\n\n");
 
   /* Check version */
-  if(asn1_check_version("0.2.6")==NULL)
+  if(asn1_check_version("0.2.11")==NULL)
     printf("\nLibrary version check ERROR:\n actual version: %s\n\n",asn1_check_version(NULL));
 
   if(1)
@@ -696,6 +696,9 @@ main(int argc,char *argv[])
 
   if(out != stdout) fclose(out);
 
+  if(errorCounter > 0)
+    return 1;
+
   exit(0);
 }