summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-10-30 11:06:45 +0000
committerSimon Josefsson <simon@josefsson.org>2006-10-30 11:06:45 +0000
commit3a5d8265cd50543f9470ef81e3ea9432ebb7ab86 (patch)
treec685ce733bd88a45b0bda8a39e31901eb78023d1 /src
parent158e8b45bb3d020bb5cf4dd389fb4f64e353781e (diff)
downloadlibtasn1-3a5d8265cd50543f9470ef81e3ea9432ebb7ab86.tar.gz
libtasn1-3a5d8265cd50543f9470ef81e3ea9432ebb7ab86.tar.bz2
libtasn1-3a5d8265cd50543f9470ef81e3ea9432ebb7ab86.zip
Handle arbitrary large DER output lenghts.
Diffstat (limited to 'src')
-rw-r--r--src/asn1Coding.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/asn1Coding.c b/src/asn1Coding.c
index 91f5325..d1867c7 100644
--- a/src/asn1Coding.c
+++ b/src/asn1Coding.c
@@ -133,7 +133,7 @@ main(int argc,char *argv[])
FILE *inputFile;
char varName[1024];
char value[1024];
- unsigned char der[1024];
+ unsigned char *der = NULL;
int der_len;
int k;
@@ -265,19 +265,28 @@ main(int argc,char *argv[])
printf("\n");
asn1_print_structure(stdout,structure,"",ASN1_PRINT_NAME_TYPE_VALUE);
- der_len=1024;
+ der_len=0;
asn1_result=asn1_der_coding(structure,"",der,&der_len,
errorDescription);
+ if (asn1_result==ASN1_MEM_ERROR)
+ {
+ der = malloc (der_len);
+ asn1_result=asn1_der_coding(structure,"",der,&der_len,
+ errorDescription);
+ }
printf("\nCoding: %s\n\n",libtasn1_strerror(asn1_result));
if(asn1_result!=ASN1_SUCCESS){
printf("asn1Coding: %s\n",errorDescription);
+ if (der)
+ free (der);
+
asn1_delete_structure(&definitions);
asn1_delete_structure(&structure);
-
+
free(inputFileAsnName);
free(inputFileAssignmentName);
-
+
exit(1);
}
@@ -286,6 +295,9 @@ main(int argc,char *argv[])
for(k=0;k<der_len;k++) printf("%02x ",der[k]);
printf("\n-----------------\n");
+ if (der)
+ free (der);
+
asn1_delete_structure(&definitions);
asn1_delete_structure(&structure);