diff options
Diffstat (limited to 'src/lib/libcrypto/x509v3/pcy_node.c')
| -rw-r--r-- | src/lib/libcrypto/x509v3/pcy_node.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/lib/libcrypto/x509v3/pcy_node.c b/src/lib/libcrypto/x509v3/pcy_node.c index 839113ea2f..ba22b267bf 100644 --- a/src/lib/libcrypto/x509v3/pcy_node.c +++ b/src/lib/libcrypto/x509v3/pcy_node.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pcy_node.c,v 1.5 2014/07/23 20:49:52 miod Exp $ */ | 1 | /* $OpenBSD: pcy_node.c,v 1.6 2015/07/18 00:01:05 beck 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 2004. | 3 | * project 2004. |
| 4 | */ | 4 | */ |
| @@ -107,23 +107,26 @@ level_find_node(const X509_POLICY_LEVEL *level, const X509_POLICY_NODE *parent, | |||
| 107 | return NULL; | 107 | return NULL; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | X509_POLICY_NODE * | 110 | |
| 111 | int | ||
| 111 | level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | 112 | level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, |
| 112 | X509_POLICY_NODE *parent, X509_POLICY_TREE *tree) | 113 | X509_POLICY_NODE *parent, X509_POLICY_TREE *tree, X509_POLICY_NODE **nodep) |
| 113 | { | 114 | { |
| 114 | X509_POLICY_NODE *node; | 115 | X509_POLICY_NODE *node = NULL; |
| 115 | 116 | ||
| 116 | node = malloc(sizeof(X509_POLICY_NODE)); | ||
| 117 | if (!node) | ||
| 118 | return NULL; | ||
| 119 | node->data = data; | ||
| 120 | node->parent = parent; | ||
| 121 | node->nchild = 0; | ||
| 122 | if (level) { | 117 | if (level) { |
| 118 | node = malloc(sizeof(X509_POLICY_NODE)); | ||
| 119 | if (!node) | ||
| 120 | goto node_error; | ||
| 121 | node->data = data; | ||
| 122 | node->parent = parent; | ||
| 123 | node->nchild = 0; | ||
| 123 | if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) { | 124 | if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) { |
| 124 | if (level->anyPolicy) | 125 | if (level->anyPolicy) |
| 125 | goto node_error; | 126 | goto node_error; |
| 126 | level->anyPolicy = node; | 127 | level->anyPolicy = node; |
| 128 | if (parent) | ||
| 129 | parent->nchild++; | ||
| 127 | } else { | 130 | } else { |
| 128 | 131 | ||
| 129 | if (!level->nodes) | 132 | if (!level->nodes) |
| @@ -132,6 +135,8 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
| 132 | goto node_error; | 135 | goto node_error; |
| 133 | if (!sk_X509_POLICY_NODE_push(level->nodes, node)) | 136 | if (!sk_X509_POLICY_NODE_push(level->nodes, node)) |
| 134 | goto node_error; | 137 | goto node_error; |
| 138 | if (parent) | ||
| 139 | parent->nchild++; | ||
| 135 | } | 140 | } |
| 136 | } | 141 | } |
| 137 | 142 | ||
| @@ -144,17 +149,20 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
| 144 | goto node_error_cond; | 149 | goto node_error_cond; |
| 145 | } | 150 | } |
| 146 | 151 | ||
| 147 | if (parent) | 152 | if (nodep) |
| 148 | parent->nchild++; | 153 | *nodep = node; |
| 149 | 154 | ||
| 150 | return node; | 155 | return 1; |
| 151 | 156 | ||
| 152 | node_error_cond: | 157 | node_error_cond: |
| 153 | if (level) | 158 | if (level) |
| 154 | node = NULL; | 159 | node = NULL; |
| 155 | node_error: | 160 | node_error: |
| 156 | policy_node_free(node); | 161 | policy_node_free(node); |
| 157 | return NULL; | 162 | node = NULL; |
| 163 | if (nodep) | ||
| 164 | *nodep = node; | ||
| 165 | return 0; | ||
| 158 | } | 166 | } |
| 159 | 167 | ||
| 160 | void | 168 | void |
