summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509v3/pcy_data.c
diff options
context:
space:
mode:
authorjsing <>2014-04-21 08:41:26 +0000
committerjsing <>2014-04-21 08:41:26 +0000
commitaf50ddfc8cd7409b6577826223496779c69cd1e0 (patch)
treef2f8e8a8d38afa820e7b749c66023be793b9ca3c /src/lib/libcrypto/x509v3/pcy_data.c
parentf46c697a11680ae5d3ab06393f0bfe2ed1841168 (diff)
downloadopenbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.tar.gz
openbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.tar.bz2
openbsd-af50ddfc8cd7409b6577826223496779c69cd1e0.zip
KNF.
Diffstat (limited to 'src/lib/libcrypto/x509v3/pcy_data.c')
-rw-r--r--src/lib/libcrypto/x509v3/pcy_data.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/lib/libcrypto/x509v3/pcy_data.c b/src/lib/libcrypto/x509v3/pcy_data.c
index 7c80915f5b..bf33bdd5d0 100644
--- a/src/lib/libcrypto/x509v3/pcy_data.c
+++ b/src/lib/libcrypto/x509v3/pcy_data.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
@@ -64,16 +64,17 @@
64 64
65/* Policy Node routines */ 65/* Policy Node routines */
66 66
67void policy_data_free(X509_POLICY_DATA *data) 67void
68 { 68policy_data_free(X509_POLICY_DATA *data)
69{
69 ASN1_OBJECT_free(data->valid_policy); 70 ASN1_OBJECT_free(data->valid_policy);
70 /* Don't free qualifiers if shared */ 71 /* Don't free qualifiers if shared */
71 if (!(data->flags & POLICY_DATA_FLAG_SHARED_QUALIFIERS)) 72 if (!(data->flags & POLICY_DATA_FLAG_SHARED_QUALIFIERS))
72 sk_POLICYQUALINFO_pop_free(data->qualifier_set, 73 sk_POLICYQUALINFO_pop_free(data->qualifier_set,
73 POLICYQUALINFO_free); 74 POLICYQUALINFO_free);
74 sk_ASN1_OBJECT_pop_free(data->expected_policy_set, ASN1_OBJECT_free); 75 sk_ASN1_OBJECT_pop_free(data->expected_policy_set, ASN1_OBJECT_free);
75 free(data); 76 free(data);
76 } 77}
77 78
78/* Create a data based on an existing policy. If 'id' is NULL use the 79/* Create a data based on an existing policy. If 'id' is NULL use the
79 * oid in the policy, otherwise use 'id'. This behaviour covers the two 80 * oid in the policy, otherwise use 'id'. This behaviour covers the two
@@ -82,32 +83,30 @@ void policy_data_free(X509_POLICY_DATA *data)
82 * another source. 83 * another source.
83 */ 84 */
84 85
85X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, 86X509_POLICY_DATA *
86 const ASN1_OBJECT *cid, int crit) 87policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *cid, int crit)
87 { 88{
88 X509_POLICY_DATA *ret; 89 X509_POLICY_DATA *ret;
89 ASN1_OBJECT *id; 90 ASN1_OBJECT *id;
91
90 if (!policy && !cid) 92 if (!policy && !cid)
91 return NULL; 93 return NULL;
92 if (cid) 94 if (cid) {
93 {
94 id = OBJ_dup(cid); 95 id = OBJ_dup(cid);
95 if (!id) 96 if (!id)
96 return NULL; 97 return NULL;
97 } 98 } else
98 else
99 id = NULL; 99 id = NULL;
100 ret = malloc(sizeof(X509_POLICY_DATA)); 100 ret = malloc(sizeof(X509_POLICY_DATA));
101 if (!ret) 101 if (!ret)
102 return NULL; 102 return NULL;
103 ret->expected_policy_set = sk_ASN1_OBJECT_new_null(); 103 ret->expected_policy_set = sk_ASN1_OBJECT_new_null();
104 if (!ret->expected_policy_set) 104 if (!ret->expected_policy_set) {
105 {
106 free(ret); 105 free(ret);
107 if (id) 106 if (id)
108 ASN1_OBJECT_free(id); 107 ASN1_OBJECT_free(id);
109 return NULL; 108 return NULL;
110 } 109 }
111 110
112 if (crit) 111 if (crit)
113 ret->flags = POLICY_DATA_FLAG_CRITICAL; 112 ret->flags = POLICY_DATA_FLAG_CRITICAL;
@@ -116,20 +115,16 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
116 115
117 if (id) 116 if (id)
118 ret->valid_policy = id; 117 ret->valid_policy = id;
119 else 118 else {
120 {
121 ret->valid_policy = policy->policyid; 119 ret->valid_policy = policy->policyid;
122 policy->policyid = NULL; 120 policy->policyid = NULL;
123 } 121 }
124 122
125 if (policy) 123 if (policy) {
126 {
127 ret->qualifier_set = policy->qualifiers; 124 ret->qualifier_set = policy->qualifiers;
128 policy->qualifiers = NULL; 125 policy->qualifiers = NULL;
129 } 126 } else
130 else
131 ret->qualifier_set = NULL; 127 ret->qualifier_set = NULL;
132 128
133 return ret; 129 return ret;
134 } 130}
135