summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_alt.c
diff options
context:
space:
mode:
authortb <>2022-03-14 21:15:49 +0000
committertb <>2022-03-14 21:15:49 +0000
commite4f8fb22773f4dee1da3875ddc02bfcfa39198f4 (patch)
treecf453def12c05205d1d4cc78cc18a174a34edfe0 /src/lib/libcrypto/x509/x509_alt.c
parent07d9625933f5867c4dee9ecde797f4222f5dc516 (diff)
downloadopenbsd-e4f8fb22773f4dee1da3875ddc02bfcfa39198f4.tar.gz
openbsd-e4f8fb22773f4dee1da3875ddc02bfcfa39198f4.tar.bz2
openbsd-e4f8fb22773f4dee1da3875ddc02bfcfa39198f4.zip
Rework ownership handling in x509_constraints_validate()
Instead of having the caller allocate and pass in a new x509_constraints_name struct, handle allocation inside x509_constraints_validate(). Also make the error optional. All this is done to simplify the call sites and to make it more obvious that there are no leaks. ok jsing
Diffstat (limited to 'src/lib/libcrypto/x509/x509_alt.c')
-rw-r--r--src/lib/libcrypto/x509/x509_alt.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/libcrypto/x509/x509_alt.c b/src/lib/libcrypto/x509/x509_alt.c
index 35aae6f185..845ab1364f 100644
--- a/src/lib/libcrypto/x509/x509_alt.c
+++ b/src/lib/libcrypto/x509/x509_alt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_alt.c,v 1.10 2022/03/13 16:48:49 tb Exp $ */ 1/* $OpenBSD: x509_alt.c,v 1.11 2022/03/14 21:15:49 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -657,17 +657,14 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method,
657 */ 657 */
658 658
659 if (is_nc) { 659 if (is_nc) {
660 struct x509_constraints_name constraints_name; 660 struct x509_constraints_name *constraints_name = NULL;
661 int error = 0;
662 661
663 memset(&constraints_name, 0, sizeof(constraints_name)); 662 if (!x509_constraints_validate(ret, &constraints_name, NULL)) {
664 type = x509_constraints_validate(ret, &constraints_name, &error);
665 if (type == 0 || error != 0) {
666 X509V3error(X509V3_R_BAD_OBJECT); 663 X509V3error(X509V3_R_BAD_OBJECT);
667 ERR_asprintf_error_data("name=%s", name); 664 ERR_asprintf_error_data("name=%s", name);
668 goto err; 665 goto err;
669 } 666 }
670 x509_constraints_name_clear(&constraints_name); 667 x509_constraints_name_free(constraints_name);
671 return ret; 668 return ret;
672 } 669 }
673 670