提交 fffc2fae 编写于 作者: V Viktor Dukhovni

Cleaner handling of "cnid" in do_x509_check

Avoid using cnid = 0, use NID_undef instead, and return early instead
of trying to find an instance of that in the subject DN.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 a0724ef1
...@@ -921,7 +921,7 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, ...@@ -921,7 +921,7 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen,
GENERAL_NAMES *gens = NULL; GENERAL_NAMES *gens = NULL;
X509_NAME *name = NULL; X509_NAME *name = NULL;
int i; int i;
int cnid; int cnid = NID_undef;
int alt_type; int alt_type;
int san_present = 0; int san_present = 0;
int rv = 0; int rv = 0;
...@@ -944,7 +944,6 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, ...@@ -944,7 +944,6 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen,
else else
equal = equal_wildcard; equal = equal_wildcard;
} else { } else {
cnid = 0;
alt_type = V_ASN1_OCTET_STRING; alt_type = V_ASN1_OCTET_STRING;
equal = equal_case; equal = equal_case;
} }
...@@ -975,11 +974,16 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, ...@@ -975,11 +974,16 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen,
GENERAL_NAMES_free(gens); GENERAL_NAMES_free(gens);
if (rv != 0) if (rv != 0)
return rv; return rv;
if (!cnid if (cnid == NID_undef
|| (san_present || (san_present
&& !(flags & X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT))) && !(flags & X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT)))
return 0; return 0;
} }
/* We're done if CN-ID is not pertinent */
if (cnid == NID_undef)
return 0;
i = -1; i = -1;
name = X509_get_subject_name(x); name = X509_get_subject_name(x);
while ((i = X509_NAME_get_index_by_NID(name, cnid, i)) >= 0) { while ((i = X509_NAME_get_index_by_NID(name, cnid, i)) >= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册