diff options
author | tb <> | 2022-03-14 21:15:49 +0000 |
---|---|---|
committer | tb <> | 2022-03-14 21:15:49 +0000 |
commit | e4f8fb22773f4dee1da3875ddc02bfcfa39198f4 (patch) | |
tree | cf453def12c05205d1d4cc78cc18a174a34edfe0 /src/lib/libcrypto/x509/x509_alt.c | |
parent | 07d9625933f5867c4dee9ecde797f4222f5dc516 (diff) | |
download | openbsd-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.c | 11 |
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 | ||