Typo.
[openssl.git] / crypto / x509v3 / pcy_tree.c
index 16cacde0c4cbdfdf9932842c2d641fc648cdbd8f..846a903e9322e463213d45620f6f0133a7e2a157 100644 (file)
@@ -81,11 +81,11 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
        X509 *x;
        int ret = 1;
        int i, n;
-       *ptree = NULL;
-       n = sk_X509_num(certs);
        int explicit_policy;
        int any_skip;
        int map_skip;
+       *ptree = NULL;
+       n = sk_X509_num(certs);
 
        /* Disable policy mapping for now... */
        flags |= X509_V_FLAG_INHIBIT_MAP;
@@ -197,7 +197,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
                        /* Any matching allowed if certificate is self
                         * issued and not the last in the chain.
                         */
-                       if (!(x->ex_flags && EXFLAG_SS) || (i == 0))
+                       if (!(x->ex_flags & EXFLAG_SS) || (i == 0))
                                level->flags |= X509_V_FLAG_INHIBIT_ANY;
                        }
                else
@@ -410,11 +410,11 @@ static int tree_add_auth_node(STACK_OF(X509_POLICY_NODE) **pnodes,
  */
 
 static int tree_calculate_authority_set(X509_POLICY_TREE *tree,
-                                       STACK_OF(X509_POLICY_NODES) **pnodes)
+                                       STACK_OF(X509_POLICY_NODE) **pnodes)
        {
        X509_POLICY_LEVEL *curr;
        X509_POLICY_NODE *node, *anyptr;
-       STACK_OF(X509_POLICY_NODES) **addnodes;
+       STACK_OF(X509_POLICY_NODE) **addnodes;
        int i, j;
        curr = tree->levels + tree->nlevel - 1;
 
@@ -589,17 +589,17 @@ void X509_policy_tree_free(X509_POLICY_TREE *tree)
  * -2  User constrained policy set empty and requireExplicit true.
  */
 
-int X509_policy_check(X509_POLICY_TREE **ptree, int *explicit,
+int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
                        STACK_OF(X509) *certs,
                        STACK_OF(ASN1_OBJECT) *policy_oids,
                        unsigned int flags)
        {
        int ret;
        X509_POLICY_TREE *tree = NULL;
-       STACK_OF(X509_NODE) *nodes, *auth_nodes = NULL;
+       STACK_OF(X509_POLICY_NODE) *nodes, *auth_nodes = NULL;
        *ptree = NULL;
 
-       *explicit = 0;
+       *pexplicit_policy = 0;
        ret = tree_init(&tree, certs, flags);
 
 
@@ -617,12 +617,12 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *explicit,
                /* Tree empty requireExplicit True: Error */
 
                case 6:
-               *explicit = 1;
+               *pexplicit_policy = 1;
                return -2;
 
                /* Tree OK requireExplicit True: OK and continue */
                case 5:
-               *explicit = 1;
+               *pexplicit_policy = 1;
                break;
 
                /* Tree OK: continue */
@@ -631,6 +631,7 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *explicit,
                break;
                }
 
+       if (!tree) goto error;
        ret = tree_evaluate(tree);
 
        if (ret <= 0)
@@ -640,7 +641,7 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *explicit,
        if (ret == 2)
                {
                X509_policy_tree_free(tree);
-               if (*explicit)
+               if (*pexplicit_policy)
                        return -2;
                else
                        return 1;
@@ -662,7 +663,7 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *explicit,
        if (tree)
                *ptree = tree;
 
-       if (*explicit)
+       if (*pexplicit_policy)
                {
                nodes = X509_policy_tree_get0_user_policies(tree);
                if (sk_X509_POLICY_NODE_num(nodes) <= 0)