diff options
author | Fabio Fiorina <fiorinaf@gnutls.org> | 2004-09-08 19:45:46 +0000 |
---|---|---|
committer | Fabio Fiorina <fiorinaf@gnutls.org> | 2004-09-08 19:45:46 +0000 |
commit | 197707eb5a4f3763e0eb6fc2364daf3af93ac93e (patch) | |
tree | 6b36c40596fb24f9bdc366d1b2454bd5a7236110 | |
parent | 8d0fdf3f39c2e745f3ebeecd2eef0d4f0d02135f (diff) | |
download | libtasn1-197707eb5a4f3763e0eb6fc2364daf3af93ac93e.tar.gz |
add self test
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lib/decoding.c | 94 | ||||
-rw-r--r-- | lib/int.h | 2 | ||||
-rw-r--r-- | lib/libtasn1.h | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/Test_parser.c | 3 | ||||
-rw-r--r-- | tests/Test_tree.c | 5 |
8 files changed, 63 insertions, 52 deletions
@@ -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. diff --git a/configure.in b/configure.in index fd7d774..01b5a57 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/lib/decoding.c b/lib/decoding.c index de3573a..b99da9f 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -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; @@ -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 diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 7efad81..8d460b1 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -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> diff --git a/tests/Makefile.am b/tests/Makefile.am index 768163e..e79017b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/Test_parser.c b/tests/Test_parser.c index 7a0688e..95fbbbf 100644 --- a/tests/Test_parser.c +++ b/tests/Test_parser.c @@ -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); } diff --git a/tests/Test_tree.c b/tests/Test_tree.c index d6c5af2..358f22d 100644 --- a/tests/Test_tree.c +++ b/tests/Test_tree.c @@ -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); } |