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