X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fx509v3%2Fv3_utl.c;h=6494d83bdb2e60ff900fb8431cf4d4497232ce91;hb=5530d5187c77877b610b11c4aadedd7107386afa;hp=d50c2fa26cdea1054283672f5187451d2e158c07;hpb=75ebbd9aa411c5b8b19ded6ace2b34181566b56a;p=openssl.git diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c index d50c2fa26c..6494d83bdb 100644 --- a/crypto/x509v3/v3_utl.c +++ b/crypto/x509v3/v3_utl.c @@ -60,9 +60,10 @@ #include #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include +#include "internal/x509_int.h" #include static char *strip_spaces(char *name); @@ -920,7 +921,7 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, GENERAL_NAMES *gens = NULL; X509_NAME *name = NULL; int i; - int cnid; + int cnid = NID_undef; int alt_type; int san_present = 0; int rv = 0; @@ -943,7 +944,6 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, else equal = equal_wildcard; } else { - cnid = 0; alt_type = V_ASN1_OCTET_STRING; equal = equal_case; } @@ -974,11 +974,16 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen, GENERAL_NAMES_free(gens); if (rv != 0) return rv; - if (!cnid + if (cnid == NID_undef || (san_present && !(flags & X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT))) return 0; } + + /* We're done if CN-ID is not pertinent */ + if (cnid == NID_undef) + return 0; + i = -1; name = X509_get_subject_name(x); while ((i = X509_NAME_get_index_by_NID(name, cnid, i)) >= 0) {