summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/asn1_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/asn1_lib.c')
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index be8daa8688..77447a5240 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -181,7 +181,7 @@ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
181 int xclass) 181 int xclass)
182 { 182 {
183 unsigned char *p= *pp; 183 unsigned char *p= *pp;
184 int i; 184 int i, ttag;
185 185
186 i=(constructed)?V_ASN1_CONSTRUCTED:0; 186 i=(constructed)?V_ASN1_CONSTRUCTED:0;
187 i|=(xclass&V_ASN1_PRIVATE); 187 i|=(xclass&V_ASN1_PRIVATE);
@@ -190,12 +190,15 @@ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
190 else 190 else
191 { 191 {
192 *(p++)=i|V_ASN1_PRIMITIVE_TAG; 192 *(p++)=i|V_ASN1_PRIMITIVE_TAG;
193 while (tag > 0x7f) 193 for(i = 0, ttag = tag; ttag > 0; i++) ttag >>=7;
194 ttag = i;
195 while(i-- > 0)
194 { 196 {
195 *(p++)=(tag&0x7f)|0x80; 197 p[i] = tag & 0x7f;
196 tag>>=7; 198 if(i != (ttag - 1)) p[i] |= 0x80;
199 tag >>= 7;
197 } 200 }
198 *(p++)=(tag&0x7f); 201 p += ttag;
199 } 202 }
200 if ((constructed == 2) && (length == 0)) 203 if ((constructed == 2) && (length == 0))
201 *(p++)=0x80; /* der_put_length would output 0 instead */ 204 *(p++)=0x80; /* der_put_length would output 0 instead */
@@ -335,9 +338,9 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
335 { 338 {
336 c=str->data; 339 c=str->data;
337 if (c == NULL) 340 if (c == NULL)
338 str->data=Malloc(len+1); 341 str->data=OPENSSL_malloc(len+1);
339 else 342 else
340 str->data=Realloc(c,len+1); 343 str->data=OPENSSL_realloc(c,len+1);
341 344
342 if (str->data == NULL) 345 if (str->data == NULL)
343 { 346 {
@@ -365,7 +368,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
365 { 368 {
366 ASN1_STRING *ret; 369 ASN1_STRING *ret;
367 370
368 ret=(ASN1_STRING *)Malloc(sizeof(ASN1_STRING)); 371 ret=(ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING));
369 if (ret == NULL) 372 if (ret == NULL)
370 { 373 {
371 ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE); 374 ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE);
@@ -381,8 +384,8 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
381void ASN1_STRING_free(ASN1_STRING *a) 384void ASN1_STRING_free(ASN1_STRING *a)
382 { 385 {
383 if (a == NULL) return; 386 if (a == NULL) return;
384 if (a->data != NULL) Free(a->data); 387 if (a->data != NULL) OPENSSL_free(a->data);
385 Free(a); 388 OPENSSL_free(a);
386 } 389 }
387 390
388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 391int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b)