From: Dr. Stephen Henson Date: Sat, 14 Apr 2007 17:53:55 +0000 (+0000) Subject: New function ASN1_STRING_copy() to copy to an already X-Git-Tag: OpenSSL_0_9_8k^2~877 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18f547734e94d4192fa6422227c1686a2d8a914e;p=thirdparty%2Fopenssl.git New function ASN1_STRING_copy() to copy to an already alloacted ASN1_STRING structure. --- diff --git a/crypto/asn1/asn1.h b/crypto/asn1/asn1.h index bed43ab6696..487d349d643 100644 --- a/crypto/asn1/asn1.h +++ b/crypto/asn1/asn1.h @@ -765,6 +765,7 @@ DECLARE_ASN1_SET_OF(ASN1_OBJECT) ASN1_STRING * ASN1_STRING_new(void); void ASN1_STRING_free(ASN1_STRING *a); +int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *a); ASN1_STRING * ASN1_STRING_type_new(int type ); int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index b2b557c24e4..1bcb44aee20 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -340,20 +340,31 @@ int asn1_GetSequence(ASN1_const_CTX *c, long *length) return(1); } +int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) + { + if (str == NULL) + return 0; + dst->type = str->type; + if (!ASN1_STRING_set(dst,str->data,str->length)) + return 0; + dst->flags = str->flags; + return 1; + } + ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) { ASN1_STRING *ret; - - if (str == NULL) return(NULL); - if ((ret=ASN1_STRING_type_new(str->type)) == NULL) - return(NULL); - if (!ASN1_STRING_set(ret,str->data,str->length)) + if (!str) + return NULL; + ret=ASN1_STRING_new(); + if (!ret) + return NULL; + if (!ASN1_STRING_copy(ret,str)) { ASN1_STRING_free(ret); - return(NULL); + return NULL; } - ret->flags = str->flags; - return(ret); + return ret; } int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)