summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2004-11-11 08:36:28 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2004-11-11 08:36:28 +0000
commit5efdf7a2869f42aa09c1f60af29466376879b4c6 (patch)
treeb0a947fdf93472a495925a050eab139a3959bb2d
parentc3bae274fadf34f1bb20d1da1d053af65750a173 (diff)
downloadgnutls-5efdf7a2869f42aa09c1f60af29466376879b4c6.tar.gz
updated to the new libtasn1.
-rw-r--r--lib/minitasn1/coding.c13
-rw-r--r--lib/minitasn1/decoding.c48
-rw-r--r--lib/minitasn1/errors.c7
-rw-r--r--lib/minitasn1/parser_aux.c20
-rw-r--r--lib/minitasn1/structure.c21
5 files changed, 74 insertions, 35 deletions
diff --git a/lib/minitasn1/coding.c b/lib/minitasn1/coding.c
index 1503f6a08b..0e922f0931 100644
--- a/lib/minitasn1/coding.c
+++ b/lib/minitasn1/coding.c
@@ -246,7 +246,7 @@ _asn1_objectid_der(unsigned char *str,unsigned char *der,int *der_len)
max_len=*der_len;
- temp=(char *) _asn1_alloca(strlen(str)+2);
+ temp= (char *) _asn1_alloca(strlen(str)+2);
if(temp==NULL) return ASN1_MEM_ALLOC_ERROR;
strcpy(temp, str);
@@ -742,7 +742,7 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len,
{
node_asn *node,*p,*p2;
char temp[SIZEOF_UNSIGNED_LONG_INT*3+1];
- int counter,counter_old,len2,len3,move,max_len,max_len_old;
+ int counter,counter_old,len2,len3,tlen,move,max_len,max_len_old;
asn1_retCode ris;
unsigned char* der = ider;
@@ -875,7 +875,9 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len,
case TYPE_SEQUENCE: case TYPE_SET:
if(move!=UP){
_asn1_ltostr(counter,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
if(p->down==NULL){
move=UP;
continue;
@@ -910,7 +912,10 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len,
case TYPE_SEQUENCE_OF: case TYPE_SET_OF:
if(move!=UP){
_asn1_ltostr(counter,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
p=p->down;
while((type_field(p->type)==TYPE_TAG) || (type_field(p->type)==TYPE_SIZE)) p=p->right;
if(p->right){
diff --git a/lib/minitasn1/decoding.c b/lib/minitasn1/decoding.c
index 714e65674b..cc01253e9c 100644
--- a/lib/minitasn1/decoding.c
+++ b/lib/minitasn1/decoding.c
@@ -492,7 +492,7 @@ _asn1_get_indefinite_length_string(const unsigned char* der,int* len)
* @element: pointer to an ASN1 structure
* @ider: vector that contains the DER encoding.
* @len: number of bytes of *der: der[0]..der[len-1]
- * Description:
+ * @errorDescription: null-terminated string contains details when an error occurred.
*
* Fill the structure *ELEMENT with values of a DER encoding string. The sructure must just be
* created with function 'create_stucture'.
@@ -514,7 +514,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
{
node_asn *node,*p,*p2,*p3;
char temp[128];
- int counter,len2,len3,len4,move,ris;
+ int counter,len2,len3,len4,move,ris,tlen;
unsigned char class,*temp2;
unsigned int tag;
int indefinite, result;
@@ -686,7 +686,9 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
break;
case TYPE_OBJECT_ID:
_asn1_get_objectid_der(der+counter,&len2, temp, sizeof(temp));
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+ if( tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
counter+=len2;
move=RIGHT;
break;
@@ -696,7 +698,9 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
asn1_delete_structure(element);
return result;
}
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
counter+=len2;
move=RIGHT;
break;
@@ -743,7 +747,9 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
counter+=len2;
if(len3>0){
_asn1_ltostr(counter+len3,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
move=DOWN;
}
else if(len3==0){
@@ -801,7 +807,10 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
if(len3){
if(len3>0){ /* definite length method */
_asn1_ltostr(counter+len3,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
}
else { /* indefinite length method */
_asn1_set_value(p,"-1",3);
@@ -938,7 +947,7 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
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;
- int counter,len2,len3,len4,move,ris;
+ int counter,len2,len3,len4,move,ris, tlen;
unsigned char class,*temp2;
unsigned int tag;
int indefinite, result;
@@ -1153,7 +1162,10 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
case TYPE_OBJECT_ID:
if(state==FOUND){
_asn1_get_objectid_der(der+counter,&len2, temp, sizeof(temp));
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
if(p==nodeFound) state=EXIT;
}
@@ -1173,7 +1185,9 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
return result;
}
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
if(p==nodeFound) state=EXIT;
}
@@ -1249,7 +1263,10 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
counter+=len2;
if(len3>0){
_asn1_ltostr(counter+len3,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+
+ if(tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
move=DOWN;
}
else if(len3==0){
@@ -1301,7 +1318,10 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName,
counter+=len2;
if(len3){
_asn1_ltostr(counter+len3,temp);
- _asn1_set_value(p,temp,strlen(temp)+1);
+ tlen = strlen(temp);
+
+ if (tlen > 0)
+ _asn1_set_value(p,temp,tlen+1);
p2=p->down;
while((type_field(p2->type)==TYPE_TAG) || (type_field(p2->type)==TYPE_SIZE)) p2=p2->right;
if(p2->right==NULL) _asn1_append_sequence_set(p);
@@ -1742,8 +1762,7 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len,
/**
- * asn1_expand_any_defined_by - Expand every "ANY DEFINED BY" fields of
- * structure *ELEMENT with the corresponding type.
+ * asn1_expand_any_defined_by - Expand "ANY DEFINED BY" fields in structure.
* @definitions: ASN1 definitions
* @element: pointer to an ASN1 structure
* Description:
@@ -1938,8 +1957,7 @@ asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element)
/**
- * asn1_expand_octet_string - Expand an "OCTET STRING" fields of
- * structure *ELEMENT with the corresponding type.
+ * asn1_expand_octet_string - Expand "OCTET STRING" fields in structure.
* @definitions: ASN1 definitions
* @element: pointer to an ASN1 structure
* @octetName: name of the OCTECT STRING field to expand.
diff --git a/lib/minitasn1/errors.c b/lib/minitasn1/errors.c
index 1313bdfe99..17654f2cee 100644
--- a/lib/minitasn1/errors.c
+++ b/lib/minitasn1/errors.c
@@ -88,8 +88,11 @@ void libtasn1_perror(asn1_retCode error)
* libtasn1_strerror - Returns a string with a description of an error
* @error: is an error returned by a libtasn1 function.
*
- * This function is similar to strerror(). The only difference is that it
- * accepts an error (number) returned by a libasn1 function.
+ * This function is similar to strerror(). The only difference is that it
+ * accepts an error (number) returned by a libasn1 function.
+ *
+ * Returns: Pointer to static zero-terminated string describing error
+ * code.
**/
const char* libtasn1_strerror(asn1_retCode error)
{
diff --git a/lib/minitasn1/parser_aux.c b/lib/minitasn1/parser_aux.c
index 8d827f5497..1da3ea611a 100644
--- a/lib/minitasn1/parser_aux.c
+++ b/lib/minitasn1/parser_aux.c
@@ -519,7 +519,7 @@ _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];
- int move;
+ int move, tlen;
if(node==NULL) return ASN1_ELEMENT_NOT_FOUND;
@@ -548,7 +548,9 @@ _asn1_expand_object_id(ASN1_TYPE node)
if(type_field(p4->type)==TYPE_CONSTANT){
p5=_asn1_add_node_only(TYPE_CONSTANT);
_asn1_set_name(p5,p4->name);
- _asn1_set_value(p5,p4->value,strlen(p4->value)+1);
+ tlen = strlen( p4->value);
+ if (tlen > 0)
+ _asn1_set_value(p5,p4->value,tlen+1);
if(p2==p){
_asn1_set_right(p5,p->down);
_asn1_set_down(p,p5);
@@ -612,7 +614,9 @@ _asn1_expand_object_id(ASN1_TYPE node)
}
p4=p4->right;
}
- _asn1_set_value(p2,name2,strlen(name2)+1);
+ tlen = strlen(name2);
+ if (tlen > 0)
+ _asn1_set_value(p2,name2,tlen+1);
}
}
move=DOWN;
@@ -871,11 +875,13 @@ parse_version_string( const char *s, int *major, int *minor, int *micro )
* asn1_check_version - This function checks the library's version
* @req_version: the version to check
*
- * Check that the version of the library is at minimum the requested one
- * and return the version string; return NULL if the condition is not
- * satisfied. If a NULL is passed to this function, no check is done,
- * but the version string is simply returned.
+ * Check library version.
*
+ * Return value: Check that the the version of the library is at
+ * minimum the one given as a string in @req_version and return the
+ * actual version string of the library; return NULL if the
+ * condition is not met. If %NULL is passed to this function no
+ * check is done and only the version string is returned.
**/
const char *
asn1_check_version( const char *req_version )
diff --git a/lib/minitasn1/structure.c b/lib/minitasn1/structure.c
index f33665476d..97f11d4cb9 100644
--- a/lib/minitasn1/structure.c
+++ b/lib/minitasn1/structure.c
@@ -342,7 +342,7 @@ node_asn *
_asn1_copy_structure3(node_asn *source_node)
{
node_asn *dest_node,*p_s,*p_d,*p_d_prev;
- int len,len2,move;
+ int len,len2,move, tlen;
if(source_node==NULL) return NULL;
@@ -365,7 +365,10 @@ _asn1_copy_structure3(node_asn *source_node)
_asn1_set_value(p_d,p_s->value,len+len2);
break;
default:
- _asn1_set_value(p_d,p_s->value,strlen(p_s->value)+1);
+ tlen = strlen(p_s->value);
+
+ if (tlen > 0)
+ _asn1_set_value(p_d,p_s->value,tlen+1);
}
}
move=DOWN;
@@ -419,7 +422,7 @@ asn1_retCode
_asn1_type_choice_config(node_asn *node)
{
node_asn *p,*p2,*p3,*p4;
- int move;
+ int move,tlen;
if(node==NULL) return ASN1_ELEMENT_NOT_FOUND;
@@ -438,7 +441,9 @@ _asn1_type_choice_config(node_asn *node)
while(p3){
if(type_field(p3->type)==TYPE_TAG){
p4=_asn1_add_node_only(p3->type);
- _asn1_set_value(p4,p3->value,strlen(p3->value)+1);
+ tlen = strlen(p3->value);
+ if (tlen > 0)
+ _asn1_set_value(p4,p3->value,tlen+1);
_asn1_set_right(p4,p2->down);
_asn1_set_down(p2,p4);
}
@@ -571,7 +576,7 @@ _asn1_expand_identifier(node_asn **node,node_asn *root)
* ASN1_ELEMENT_NOT_FOUND\: SOURCE_NAME isn't known
*
* Example: using "pkix.asn"
- * result=asn1_create_structure(cert_def,"PKIX1.Certificate",&cert);
+ * result=asn1_create_structure(cert_def,"PKIX1.Certificate",certptr);
**/
asn1_retCode
asn1_create_element(ASN1_TYPE definitions,const char *source_name,
@@ -600,6 +605,9 @@ asn1_create_element(ASN1_TYPE definitions,const char *source_name,
* @out: pointer to the output file (e.g. stdout).
* @structure: pointer to the structure that you want to visit.
* @name: an element of the structure
+ * @mode: specify how much of the structure to print, can be
+ * ASN1_PRINT_NAME, ASN1_PRINT_NAME_TYPE,
+ * ASN1_PRINT_NAME_TYPE_VALUE, or ASN1_PRINT_ALL.
*
* Prints on the standard output the structure's tree starting from the NAME element inside
* the structure *POINTER.
@@ -894,8 +902,7 @@ asn1_number_of_elements(ASN1_TYPE element,const char *name,int *num)
/**
- * asn1_find_structure_from_oid - Search the structure that is defined just
- * after an OID definition.
+ * asn1_find_structure_from_oid - Locate structure defined by a specific OID.
* @definitions: ASN1 definitions
* @oidValue: value of the OID to search (e.g. "1.2.3.4").
* Description: