summaryrefslogtreecommitdiff
path: root/crypto/x509/x_x509.c
diff options
context:
space:
mode:
authorPaul Yang <yang.yang@baishancloud.com>2019-04-01 10:21:53 +0900
committerPaul Yang <yang.yang@baishancloud.com>2019-04-09 20:44:42 +0800
commitccf453610f48fe88968f0cfc63784b503eae33a0 (patch)
treee91e6430ea6e7062bc01b31d686a0d79581c9e93 /crypto/x509/x_x509.c
parentbbcaef632440067d173e2c4bfc40dd96ef2c0112 (diff)
downloadopenssl-new-ccf453610f48fe88968f0cfc63784b503eae33a0.tar.gz
Make X509_set_sm2_id consistent with other setters
This commit makes the X509_set_sm2_id to 'set0' behaviour, which means the memory management is passed to X509 and user doesn't need to free the sm2_id parameter later. API name also changes to X509_set0_sm2_id. Document and test case are also updated. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8626)
Diffstat (limited to 'crypto/x509/x_x509.c')
-rw-r--r--crypto/x509/x_x509.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c
index 901a3e6a92..78e1a7569e 100644
--- a/crypto/x509/x_x509.c
+++ b/crypto/x509/x_x509.c
@@ -73,6 +73,9 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
ret->rfc3779_addr = NULL;
ret->rfc3779_asid = NULL;
#endif
+#ifndef OPENSSL_NO_SM2
+ ret->sm2_id = NULL;
+#endif
ret->aux = NULL;
ret->crldp = NULL;
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data))
@@ -92,6 +95,9 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
ASIdentifiers_free(ret->rfc3779_asid);
#endif
+#ifndef OPENSSL_NO_SM2
+ ASN1_OCTET_STRING_free(ret->sm2_id);
+#endif
break;
}
@@ -246,13 +252,14 @@ int X509_get_signature_nid(const X509 *x)
}
#ifndef OPENSSL_NO_SM2
-void X509_set_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id)
+void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id)
{
- x->sm2_id = *sm2_id;
+ ASN1_OCTET_STRING_free(x->sm2_id);
+ x->sm2_id = sm2_id;
}
ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x)
{
- return &x->sm2_id;
+ return x->sm2_id;
}
#endif