diff options
author | jsing <> | 2014-04-21 08:41:26 +0000 |
---|---|---|
committer | jsing <> | 2014-04-21 08:41:26 +0000 |
commit | af50ddfc8cd7409b6577826223496779c69cd1e0 (patch) | |
tree | f2f8e8a8d38afa820e7b749c66023be793b9ca3c /src/lib/libcrypto/x509v3/pcy_map.c | |
parent | f46c697a11680ae5d3ab06393f0bfe2ed1841168 (diff) | |
download | openbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.tar.gz openbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.tar.bz2 openbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.zip |
KNF.
Diffstat (limited to 'src/lib/libcrypto/x509v3/pcy_map.c')
-rw-r--r-- | src/lib/libcrypto/x509v3/pcy_map.c | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/src/lib/libcrypto/x509v3/pcy_map.c b/src/lib/libcrypto/x509v3/pcy_map.c index 21163b529d..295988a411 100644 --- a/src/lib/libcrypto/x509v3/pcy_map.c +++ b/src/lib/libcrypto/x509v3/pcy_map.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -66,28 +66,27 @@ | |||
66 | * Note: this modifies the passed POLICY_MAPPINGS structure | 66 | * Note: this modifies the passed POLICY_MAPPINGS structure |
67 | */ | 67 | */ |
68 | 68 | ||
69 | int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps) | 69 | int |
70 | { | 70 | policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps) |
71 | { | ||
71 | POLICY_MAPPING *map; | 72 | POLICY_MAPPING *map; |
72 | X509_POLICY_DATA *data; | 73 | X509_POLICY_DATA *data; |
73 | X509_POLICY_CACHE *cache = x->policy_cache; | 74 | X509_POLICY_CACHE *cache = x->policy_cache; |
74 | int i; | 75 | int i; |
75 | int ret = 0; | 76 | int ret = 0; |
76 | if (sk_POLICY_MAPPING_num(maps) == 0) | 77 | |
77 | { | 78 | if (sk_POLICY_MAPPING_num(maps) == 0) { |
78 | ret = -1; | 79 | ret = -1; |
79 | goto bad_mapping; | 80 | goto bad_mapping; |
80 | } | 81 | } |
81 | for (i = 0; i < sk_POLICY_MAPPING_num(maps); i++) | 82 | for (i = 0; i < sk_POLICY_MAPPING_num(maps); i++) { |
82 | { | ||
83 | map = sk_POLICY_MAPPING_value(maps, i); | 83 | map = sk_POLICY_MAPPING_value(maps, i); |
84 | /* Reject if map to or from anyPolicy */ | 84 | /* Reject if map to or from anyPolicy */ |
85 | if ((OBJ_obj2nid(map->subjectDomainPolicy) == NID_any_policy) | 85 | if ((OBJ_obj2nid(map->subjectDomainPolicy) == NID_any_policy) || |
86 | || (OBJ_obj2nid(map->issuerDomainPolicy) == NID_any_policy)) | 86 | (OBJ_obj2nid(map->issuerDomainPolicy) == NID_any_policy)) { |
87 | { | ||
88 | ret = -1; | 87 | ret = -1; |
89 | goto bad_mapping; | 88 | goto bad_mapping; |
90 | } | 89 | } |
91 | 90 | ||
92 | /* Attempt to find matching policy data */ | 91 | /* Attempt to find matching policy data */ |
93 | data = policy_cache_find_data(cache, map->issuerDomainPolicy); | 92 | data = policy_cache_find_data(cache, map->issuerDomainPolicy); |
@@ -96,37 +95,33 @@ int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps) | |||
96 | continue; | 95 | continue; |
97 | 96 | ||
98 | /* Create a NODE from anyPolicy */ | 97 | /* Create a NODE from anyPolicy */ |
99 | if (!data) | 98 | if (!data) { |
100 | { | ||
101 | data = policy_data_new(NULL, map->issuerDomainPolicy, | 99 | data = policy_data_new(NULL, map->issuerDomainPolicy, |
102 | cache->anyPolicy->flags | 100 | cache->anyPolicy->flags & |
103 | & POLICY_DATA_FLAG_CRITICAL); | 101 | POLICY_DATA_FLAG_CRITICAL); |
104 | if (!data) | 102 | if (!data) |
105 | goto bad_mapping; | 103 | goto bad_mapping; |
106 | data->qualifier_set = cache->anyPolicy->qualifier_set; | 104 | data->qualifier_set = cache->anyPolicy->qualifier_set; |
107 | /*map->issuerDomainPolicy = NULL;*/ | 105 | /*map->issuerDomainPolicy = NULL;*/ |
108 | data->flags |= POLICY_DATA_FLAG_MAPPED_ANY; | 106 | data->flags |= POLICY_DATA_FLAG_MAPPED_ANY; |
109 | data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; | 107 | data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; |
110 | if (!sk_X509_POLICY_DATA_push(cache->data, data)) | 108 | if (!sk_X509_POLICY_DATA_push(cache->data, data)) { |
111 | { | ||
112 | policy_data_free(data); | 109 | policy_data_free(data); |
113 | goto bad_mapping; | 110 | goto bad_mapping; |
114 | } | ||
115 | } | 111 | } |
116 | else | 112 | } else |
117 | data->flags |= POLICY_DATA_FLAG_MAPPED; | 113 | data->flags |= POLICY_DATA_FLAG_MAPPED; |
118 | if (!sk_ASN1_OBJECT_push(data->expected_policy_set, | 114 | if (!sk_ASN1_OBJECT_push(data->expected_policy_set, |
119 | map->subjectDomainPolicy)) | 115 | map->subjectDomainPolicy)) |
120 | goto bad_mapping; | 116 | goto bad_mapping; |
121 | map->subjectDomainPolicy = NULL; | 117 | map->subjectDomainPolicy = NULL; |
122 | 118 | } | |
123 | } | ||
124 | 119 | ||
125 | ret = 1; | 120 | ret = 1; |
126 | bad_mapping: | 121 | |
122 | bad_mapping: | ||
127 | if (ret == -1) | 123 | if (ret == -1) |
128 | x->ex_flags |= EXFLAG_INVALID_POLICY; | 124 | x->ex_flags |= EXFLAG_INVALID_POLICY; |
129 | sk_POLICY_MAPPING_pop_free(maps, POLICY_MAPPING_free); | 125 | sk_POLICY_MAPPING_pop_free(maps, POLICY_MAPPING_free); |
130 | return ret; | 126 | return ret; |
131 | 127 | } | |
132 | } | ||