代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/openssl 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From a63238684c1d2e15f417f766f44418a8b52ef383 Mon Sep 17 00:00:00 2001
From: Paul Yang <kaishen.yy@antfin.com>
Date: Sat, 21 Sep 2019 00:32:57 +0800
Subject: [PATCH 12/15] Fix a double free issue when signing SM2 cert
If the SM2 ID value has not been passed correctly when signing an SM2
certificate/certificate request, a double free occurs. For instance:
openssl req -x509 ... -sm2-id 1234567812345678
The '-sm2-id' should not be used in this scenario, while the '-sigopt' is
the correct one to use. Documentation has also been updated to make the
options more clear.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9958)
---
apps/req.c | 48 ++++++++++++++++++++++++++++++------------------
doc/man1/req.pod | 4 ++--
2 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/apps/req.c b/apps/req.c
index 96f1edd..95dd0e4 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -1756,15 +1756,19 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif
rv = do_sign_init(mctx, pkey, md, sigopts);
- if (rv > 0)
+ if (rv > 0) {
rv = X509_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2
- /* only in SM2 case we need to free the pctx explicitly */
- if (ec_pkey_is_sm2(pkey)) {
- pctx = EVP_MD_CTX_pkey_ctx(mctx);
- EVP_PKEY_CTX_free(pctx);
- }
+ /*
+ * only in SM2 case we need to free the pctx explicitly
+ * if do_sign_init() fails, pctx is already freed in it
+ */
+ if (ec_pkey_is_sm2(pkey)) {
+ pctx = EVP_MD_CTX_pkey_ctx(mctx);
+ EVP_PKEY_CTX_free(pctx);
+ }
#endif
+ }
EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
@@ -1779,15 +1783,19 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif
rv = do_sign_init(mctx, pkey, md, sigopts);
- if (rv > 0)
+ if (rv > 0) {
rv = X509_REQ_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2
- /* only in SM2 case we need to free the pctx explicitly */
- if (ec_pkey_is_sm2(pkey)) {
- pctx = EVP_MD_CTX_pkey_ctx(mctx);
- EVP_PKEY_CTX_free(pctx);
- }
+ /*
+ * only in SM2 case we need to free the pctx explicitly
+ * if do_sign_init() fails, pctx is already freed in it
+ */
+ if (ec_pkey_is_sm2(pkey)) {
+ pctx = EVP_MD_CTX_pkey_ctx(mctx);
+ EVP_PKEY_CTX_free(pctx);
+ }
#endif
+ }
EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
@@ -1802,15 +1810,19 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif
rv = do_sign_init(mctx, pkey, md, sigopts);
- if (rv > 0)
+ if (rv > 0) {
rv = X509_CRL_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2
- /* only in SM2 case we need to free the pctx explicitly */
- if (ec_pkey_is_sm2(pkey)) {
- pctx = EVP_MD_CTX_pkey_ctx(mctx);
- EVP_PKEY_CTX_free(pctx);
- }
+ /*
+ * only in SM2 case we need to free the pctx explicitly
+ * if do_sign_init() fails, no need to double free pctx
+ */
+ if (ec_pkey_is_sm2(pkey)) {
+ pctx = EVP_MD_CTX_pkey_ctx(mctx);
+ EVP_PKEY_CTX_free(pctx);
+ }
#endif
+ }
EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
diff --git a/doc/man1/req.pod b/doc/man1/req.pod
index 3b9fcc3..7b00bad 100644
--- a/doc/man1/req.pod
+++ b/doc/man1/req.pod
@@ -343,8 +343,8 @@ for key generation operations.
=item B<-sm2-id>
-Specify the ID string to use when verifying an SM2 certificate. The ID string is
-required by the SM2 signature algorithm for signing and verification.
+Specify the ID string to use when verifying an SM2 certificate request. The ID
+string is required by the SM2 signature algorithm for signing and verification.
=item B<-sm2-hex-id>
--
2.20.1 (Apple Git-117)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。