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.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 5af559ef8d..1bcb44aee2 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -340,20 +340,31 @@ int asn1_GetSequence(ASN1_const_CTX *c, long *length)
340 return(1); 340 return(1);
341 } 341 }
342 342
343ASN1_STRING *ASN1_STRING_dup(ASN1_STRING *str) 343int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
344 { 344 {
345 ASN1_STRING *ret; 345 if (str == NULL)
346 return 0;
347 dst->type = str->type;
348 if (!ASN1_STRING_set(dst,str->data,str->length))
349 return 0;
350 dst->flags = str->flags;
351 return 1;
352 }
346 353
347 if (str == NULL) return(NULL); 354ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str)
348 if ((ret=ASN1_STRING_type_new(str->type)) == NULL) 355 {
349 return(NULL); 356 ASN1_STRING *ret;
350 if (!ASN1_STRING_set(ret,str->data,str->length)) 357 if (!str)
358 return NULL;
359 ret=ASN1_STRING_new();
360 if (!ret)
361 return NULL;
362 if (!ASN1_STRING_copy(ret,str))
351 { 363 {
352 ASN1_STRING_free(ret); 364 ASN1_STRING_free(ret);
353 return(NULL); 365 return NULL;
354 } 366 }
355 ret->flags = str->flags; 367 return ret;
356 return(ret);
357 } 368 }
358 369
359int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) 370int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
@@ -427,11 +438,12 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
427void ASN1_STRING_free(ASN1_STRING *a) 438void ASN1_STRING_free(ASN1_STRING *a)
428 { 439 {
429 if (a == NULL) return; 440 if (a == NULL) return;
430 if (a->data != NULL) OPENSSL_free(a->data); 441 if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
442 OPENSSL_free(a->data);
431 OPENSSL_free(a); 443 OPENSSL_free(a);
432 } 444 }
433 445
434int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 446int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
435 { 447 {
436 int i; 448 int i;
437 449
@@ -457,7 +469,7 @@ void asn1_add_error(const unsigned char *address, int offset)
457 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 469 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
458 } 470 }
459 471
460int ASN1_STRING_length(ASN1_STRING *x) 472int ASN1_STRING_length(const ASN1_STRING *x)
461{ return M_ASN1_STRING_length(x); } 473{ return M_ASN1_STRING_length(x); }
462 474
463void ASN1_STRING_length_set(ASN1_STRING *x, int len) 475void ASN1_STRING_length_set(ASN1_STRING *x, int len)