From 2fdda6dc8ae0053f72f1e21dcab781d9da81d172 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Wed, 8 Oct 2008 15:23:13 +0200 Subject: Update usages of MAX_* constants. --- doc/libtasn1.texi | 6 +++--- examples/CertificateExample.c | 8 ++++---- examples/CrlExample.c | 8 ++++---- lib/ASN1.c | 14 +++++++------- lib/ASN1.y | 14 +++++++------- lib/coding.c | 2 +- lib/decoding.c | 18 +++++++++--------- lib/gstr.h | 4 ++-- lib/parser_aux.c | 8 ++++---- lib/structure.c | 8 ++++---- src/asn1Coding.c | 2 +- src/asn1Decoding.c | 2 +- src/asn1Parser.c | 2 +- tests/Test_encoding.c | 2 +- tests/Test_parser.c | 4 ++-- tests/Test_tree.c | 2 +- 16 files changed, 52 insertions(+), 52 deletions(-) diff --git a/doc/libtasn1.texi b/doc/libtasn1.texi index cf2b580..382f1e5 100644 --- a/doc/libtasn1.texi +++ b/doc/libtasn1.texi @@ -247,10 +247,10 @@ initialization. For example: Some functions require a parameter named errorDescription of char* type. The array must be already allocated and must have at least -@code{MAX_ERROR_DESCRIPTION_SIZE} bytes (E.g, as in @code{char -Description[MAX_ERROR_DESCRIPTION_SIZE];}). +@code{ASN1_MAX_ERROR_DESCRIPTION_SIZE} bytes (E.g, as in @code{char +Description[ASN1_MAX_ERROR_DESCRIPTION_SIZE];}). -@code{MAX_NAME_SIZE} indicates the maximum number of characters of a +@code{ASN1_MAX_NAME_SIZE} indicates the maximum number of characters of a name inside a file with ASN1 definitions. @node Future developments diff --git a/examples/CertificateExample.c b/examples/CertificateExample.c index 5af525e..7debe73 100644 --- a/examples/CertificateExample.c +++ b/examples/CertificateExample.c @@ -73,7 +73,7 @@ get_Name_type(node_asn *cert_def,node_asn *cert,char *root, char *answer) int k,k2,result,len; char name[128],str[1024],str2[1024],name2[128],counter[5],name3[128]; ASN1_TYPE value=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; answer[0]=0; k=1; @@ -186,7 +186,7 @@ create_certificate(node_asn *cert_def,unsigned char *der,int *der_len) ASN1_TYPE value=ASN1_TYPE_EMPTY; ASN1_TYPE param=ASN1_TYPE_EMPTY; ASN1_TYPE constr=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; int max_len; max_len=*der_len; @@ -430,7 +430,7 @@ get_certificate(node_asn *cert_def,unsigned char *der,int der_len) int result,len,start,end; unsigned char str[1024],str2[1024]; ASN1_TYPE cert2=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; asn1_create_element(cert_def,"PKIX1Implicit88.Certificate",&cert2); @@ -495,7 +495,7 @@ main(int argc,char *argv[]) int result,der_len; unsigned char der[1024]; ASN1_TYPE PKIX1Implicit88=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if(1) result=asn1_array2tree(pkix_asn1_tab,&PKIX1Implicit88,errorDescription); diff --git a/examples/CrlExample.c b/examples/CrlExample.c index fbc200b..725d5c3 100644 --- a/examples/CrlExample.c +++ b/examples/CrlExample.c @@ -75,7 +75,7 @@ get_Name_type(node_asn *cert_def,node_asn *cert,char *root, char *answer) int k,k2,result,len; char name[128],str[1024],str2[1024],name2[128],counter[5],name3[128]; ASN1_TYPE value=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; answer[0]=0; k=1; @@ -194,7 +194,7 @@ create_CRL(node_asn *cert_def, unsigned char *der,int *der_len) unsigned char str[1024],*str2; ASN1_TYPE crl=ASN1_TYPE_EMPTY; ASN1_TYPE value=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; int max_len; max_len=*der_len; @@ -354,7 +354,7 @@ get_CRL(node_asn *cert_def,unsigned char *der,int der_len) int result,len,start,end; unsigned char str[1024],str2[1024]; ASN1_TYPE crl2=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; asn1_create_element(cert_def,"PKIX1Implicit88.CertificateList",&crl2); @@ -414,7 +414,7 @@ main(int argc,char *argv[]) int result,der_len; unsigned char der[1024]; ASN1_TYPE PKIX1Implicit88=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if(1) result=asn1_array2tree(pkix_asn1_tab,&PKIX1Implicit88,errorDescription); diff --git a/lib/ASN1.c b/lib/ASN1.c index aa3d38b..6ddb65c 100644 --- a/lib/ASN1.c +++ b/lib/ASN1.c @@ -175,7 +175,7 @@ static node_asn *p_tree; /* pointer to the root of the static unsigned long lineNumber; /* line number describing the parser position inside the file */ -static char lastToken[MAX_NAME_SIZE+1]; /* last token find in the file +static char lastToken[ASN1_MAX_NAME_SIZE+1]; /* last token find in the file to parse before the 'parse error' */ extern char _asn1_identifierMissing[]; @@ -209,7 +209,7 @@ typedef union YYSTYPE #line 62 "ASN1.y" { unsigned int constant; - char str[MAX_NAME_SIZE+1]; + char str[ASN1_MAX_NAME_SIZE+1]; node_asn* node; } /* Line 187 of yacc.c. */ @@ -2381,7 +2381,7 @@ int _asn1_yylex() { int c,counter=0,k,lastc; - char string[MAX_NAME_SIZE+1]; /* will contain the next token */ + char string[ASN1_MAX_NAME_SIZE+1]; /* will contain the next token */ while(1) { @@ -2428,7 +2428,7 @@ _asn1_yylex() c=='(' || c==')' || c=='[' || c==']' || c=='{' || c=='}' || c==',' || c=='.')) { - if(counter>=MAX_NAME_SIZE){ + if(counter>=ASN1_MAX_NAME_SIZE){ result_parse=ASN1_NAME_TOO_LONG; return 0; } @@ -2490,7 +2490,7 @@ _asn1_create_errorDescription(int error,char *errorDescription) strcat(errorDescription,":"); _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1); strcat(errorDescription,": name too long (more than "); - _asn1_ltostr(MAX_NAME_SIZE,errorDescription+strlen(errorDescription)); + _asn1_ltostr(ASN1_MAX_NAME_SIZE,errorDescription+strlen(errorDescription)); strcat(errorDescription," characters)"); } break; @@ -2538,7 +2538,7 @@ _asn1_create_errorDescription(int error,char *errorDescription) * is not defined. * * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more - * than MAX_NAME_SIZE characters. + * than ASN1_MAX_NAME_SIZE characters. **/ asn1_retCode asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions, @@ -2629,7 +2629,7 @@ asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions, * is not defined. * * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more - * than MAX_NAME_SIZE characters. + * than ASN1_MAX_NAME_SIZE characters. **/ int asn1_parser2array(const char *inputFileName,const char *outputFileName, const char *vectorName,char *errorDescription){ diff --git a/lib/ASN1.y b/lib/ASN1.y index 7fac39e..43840ca 100644 --- a/lib/ASN1.y +++ b/lib/ASN1.y @@ -45,7 +45,7 @@ static node_asn *p_tree; /* pointer to the root of the static unsigned long lineNumber; /* line number describing the parser position inside the file */ -static char lastToken[MAX_NAME_SIZE+1]; /* last token find in the file +static char lastToken[ASN1_MAX_NAME_SIZE+1]; /* last token find in the file to parse before the 'parse error' */ extern char _asn1_identifierMissing[]; @@ -61,7 +61,7 @@ int _asn1_yylex(void); %union { unsigned int constant; - char str[MAX_NAME_SIZE+1]; + char str[ASN1_MAX_NAME_SIZE+1]; node_asn* node; } @@ -429,7 +429,7 @@ int _asn1_yylex() { int c,counter=0,k,lastc; - char string[MAX_NAME_SIZE+1]; /* will contain the next token */ + char string[ASN1_MAX_NAME_SIZE+1]; /* will contain the next token */ while(1) { @@ -476,7 +476,7 @@ _asn1_yylex() c=='(' || c==')' || c=='[' || c==']' || c=='{' || c=='}' || c==',' || c=='.')) { - if(counter>=MAX_NAME_SIZE){ + if(counter>=ASN1_MAX_NAME_SIZE){ result_parse=ASN1_NAME_TOO_LONG; return 0; } @@ -538,7 +538,7 @@ _asn1_create_errorDescription(int error,char *errorDescription) strcat(errorDescription,":"); _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1); strcat(errorDescription,": name too long (more than "); - _asn1_ltostr(MAX_NAME_SIZE,errorDescription+strlen(errorDescription)); + _asn1_ltostr(ASN1_MAX_NAME_SIZE,errorDescription+strlen(errorDescription)); strcat(errorDescription," characters)"); } break; @@ -586,7 +586,7 @@ _asn1_create_errorDescription(int error,char *errorDescription) * is not defined. * * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more - * than MAX_NAME_SIZE characters. + * than ASN1_MAX_NAME_SIZE characters. **/ asn1_retCode asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions, @@ -677,7 +677,7 @@ asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions, * is not defined. * * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more - * than MAX_NAME_SIZE characters. + * than ASN1_MAX_NAME_SIZE characters. **/ int asn1_parser2array(const char *inputFileName,const char *outputFileName, const char *vectorName,char *errorDescription){ diff --git a/lib/coding.c b/lib/coding.c index 74c8390..e9fb91a 100644 --- a/lib/coding.c +++ b/lib/coding.c @@ -55,7 +55,7 @@ _asn1_error_description_value_not_found (node_asn * node, Estrcpy (ErrorDescription, ":: value of element '"); _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), - MAX_ERROR_DESCRIPTION_SIZE - 40); + ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40); Estrcat (ErrorDescription, "' not found"); } diff --git a/lib/decoding.c b/lib/decoding.c index c1de9e6..223fe1d 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -40,7 +40,7 @@ _asn1_error_description_tag_error (node_asn * node, char *ErrorDescription) Estrcpy (ErrorDescription, ":: tag error near element '"); _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), - MAX_ERROR_DESCRIPTION_SIZE - 40); + ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40); Estrcat (ErrorDescription, "'"); } @@ -1327,8 +1327,8 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, const void *ider, int len, char *errorDescription) { node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY; - char temp[128], currentName[MAX_NAME_SIZE * 10], *dot_p, *char_p; - int nameLen = MAX_NAME_SIZE * 10 - 1, state; + char temp[128], currentName[ASN1_MAX_NAME_SIZE * 10], *dot_p, *char_p; + int nameLen = ASN1_MAX_NAME_SIZE * 10 - 1, state; int counter, len2, len3, len4, move, ris, tlen; unsigned char class, *temp2; unsigned long tag; @@ -2461,12 +2461,12 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, asn1_retCode asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) { - char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1], - value[MAX_NAME_SIZE]; + char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1], + value[ASN1_MAX_NAME_SIZE]; asn1_retCode retCode = ASN1_SUCCESS, result; int len, len2, len3; ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY)) return ASN1_ELEMENT_NOT_FOUND; @@ -2550,7 +2550,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) strcpy (name, definitionsName); strcat (name, p2->name); - len = MAX_NAME_SIZE; + len = ASN1_MAX_NAME_SIZE; result = asn1_read_value (definitions, name, value, &len); @@ -2700,12 +2700,12 @@ asn1_retCode asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, const char *octetName, const char *objectName) { - char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE]; + char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE]; asn1_retCode retCode = ASN1_SUCCESS, result; int len, len2, len3; ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY; ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY)) return ASN1_ELEMENT_NOT_FOUND; diff --git a/lib/gstr.h b/lib/gstr.h index 5508d26..992fd0f 100644 --- a/lib/gstr.h +++ b/lib/gstr.h @@ -1,5 +1,5 @@ void _asn1_str_cpy( char* dest, size_t dest_tot_size, const char* src); void _asn1_str_cat( char* dest, size_t dest_tot_size, const char* src); -#define Estrcpy(x,y) _asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y) -#define Estrcat(x,y) _asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y) +#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y) +#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y) diff --git a/lib/parser_aux.c b/lib/parser_aux.c index 51169b1..e4665a3 100644 --- a/lib/parser_aux.c +++ b/lib/parser_aux.c @@ -27,7 +27,7 @@ #include "structure.h" #include "element.h" -char _asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ +char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1]; /* identifier name not found */ /***********************************************/ /* Type: list_type */ @@ -95,7 +95,7 @@ ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name) { node_asn *p; - char *n_end, n[MAX_NAME_SIZE + 1]; + char *n_end, n[ASN1_MAX_NAME_SIZE + 1]; const char *n_start; if (pointer == NULL) @@ -582,7 +582,7 @@ asn1_retCode _asn1_expand_object_id (ASN1_TYPE node) { node_asn *p, *p2, *p3, *p4, *p5; - char name_root[MAX_NAME_SIZE], name2[2 * MAX_NAME_SIZE + 1]; + char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1]; int move, tlen; if (node == NULL) @@ -836,7 +836,7 @@ asn1_retCode _asn1_check_identifier (ASN1_TYPE node) { node_asn *p, *p2; - char name2[MAX_NAME_SIZE * 2 + 2]; + char name2[ASN1_MAX_NAME_SIZE * 2 + 2]; if (node == NULL) return ASN1_ELEMENT_NOT_FOUND; diff --git a/lib/structure.c b/lib/structure.c index 743e9ba..8876e72 100644 --- a/lib/structure.c +++ b/lib/structure.c @@ -556,7 +556,7 @@ asn1_retCode _asn1_expand_identifier (node_asn ** node, node_asn * root) { node_asn *p, *p2, *p3; - char name2[MAX_NAME_SIZE + 2]; + char name2[ASN1_MAX_NAME_SIZE + 2]; int move; if (node == NULL) @@ -1127,8 +1127,8 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num) const char * asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) { - char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1]; - char value[MAX_NAME_SIZE]; + char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1]; + char value[ASN1_MAX_NAME_SIZE]; ASN1_TYPE p; int len; asn1_retCode result; @@ -1150,7 +1150,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) strcpy (name, definitionsName); strcat (name, p->name); - len = MAX_NAME_SIZE; + len = ASN1_MAX_NAME_SIZE; result = asn1_read_value (definitions, name, value, &len); if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value))) diff --git a/src/asn1Coding.c b/src/asn1Coding.c index b0b7894..4cb763f 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -126,7 +126,7 @@ main(int argc,char *argv[]) int checkSyntaxOnly=0; ASN1_TYPE definitions=ASN1_TYPE_EMPTY; ASN1_TYPE structure=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; int asn1_result=ASN1_SUCCESS; FILE *outputFile; FILE *inputFile; diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index 87ce973..e6ee47f 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -73,7 +73,7 @@ main(int argc,char *argv[]) int checkSyntaxOnly=0; ASN1_TYPE definitions=ASN1_TYPE_EMPTY; ASN1_TYPE structure=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; int asn1_result=ASN1_SUCCESS; unsigned char *der; int der_len=0; diff --git a/src/asn1Parser.c b/src/asn1Parser.c index b968f22..b591f79 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -76,7 +76,7 @@ main(int argc,char *argv[]) char *vectorName=NULL; int checkSyntaxOnly=0; ASN1_TYPE pointer=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; int parse_result=ASN1_SUCCESS; set_program_name (argv[0]); diff --git a/tests/Test_encoding.c b/tests/Test_encoding.c index 4b96727..0429d3c 100644 --- a/tests/Test_encoding.c +++ b/tests/Test_encoding.c @@ -40,7 +40,7 @@ main (int argc, char *argv[]) asn1_retCode result; ASN1_TYPE definitions = ASN1_TYPE_EMPTY; ASN1_TYPE asn1_element = ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; const char *treefile = getenv ("ASN1ENCODING"); if (!treefile) diff --git a/tests/Test_parser.c b/tests/Test_parser.c index e832180..72b0183 100644 --- a/tests/Test_parser.c +++ b/tests/Test_parser.c @@ -49,7 +49,7 @@ test_type test_array[]={ ASN1_SYNTAX_ERROR,_FILE_":6: parse error near 'TEST_PARSER'"}, {6,"TEST_PARSER { }",ASN1_SUCCESS,""}, - /* Test MAX_NAME_SIZE (128) */ + /* Test ASN1_MAX_NAME_SIZE (128) */ {12,"a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 ::= INTEGER", ASN1_SUCCESS,""}, {12,"a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 ::= INTEGER", @@ -145,7 +145,7 @@ main(int argc,char *argv[]) { asn1_retCode result; ASN1_TYPE definitions=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; test_type *test; int errorCounter=0,testCounter=0; diff --git a/tests/Test_tree.c b/tests/Test_tree.c index 679f52f..96bad24 100644 --- a/tests/Test_tree.c +++ b/tests/Test_tree.c @@ -421,7 +421,7 @@ main(int argc,char *argv[]) asn1_retCode result; ASN1_TYPE definitions=ASN1_TYPE_EMPTY; ASN1_TYPE asn1_element=ASN1_TYPE_EMPTY; - char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; + char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; FILE *out; test_type *test; int errorCounter=0,testCounter=0,der_len; -- cgit v1.2.3