summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509v3
diff options
context:
space:
mode:
authorbeck <>2014-04-17 13:37:50 +0000
committerbeck <>2014-04-17 13:37:50 +0000
commitbddb7c686e3d1aeb156722adc64b6c35ae720f87 (patch)
tree7595a93a27385c367802aa17ecf20f96551cf14d /src/lib/libcrypto/x509v3
parentecec66222d758996a4ff2671ca5026d9ede5ef76 (diff)
downloadopenbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.tar.gz
openbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.tar.bz2
openbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.zip
Change library to use intrinsic memory allocation functions instead of
OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
Diffstat (limited to 'src/lib/libcrypto/x509v3')
-rw-r--r--src/lib/libcrypto/x509v3/pcy_cache.c4
-rw-r--r--src/lib/libcrypto/x509v3/pcy_data.c6
-rw-r--r--src/lib/libcrypto/x509v3/pcy_node.c4
-rw-r--r--src/lib/libcrypto/x509v3/pcy_tree.c18
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c6
-rw-r--r--src/lib/libcrypto/x509v3/v3_akey.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_asid.c10
-rw-r--r--src/lib/libcrypto/x509v3/v3_conf.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_cpols.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_ia5.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c10
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_pci.c10
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c14
-rw-r--r--src/lib/libcrypto/x509v3/v3_sxnet.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c40
18 files changed, 73 insertions, 73 deletions
diff --git a/src/lib/libcrypto/x509v3/pcy_cache.c b/src/lib/libcrypto/x509v3/pcy_cache.c
index 172b7e7ee4..24c79b4a80 100644
--- a/src/lib/libcrypto/x509v3/pcy_cache.c
+++ b/src/lib/libcrypto/x509v3/pcy_cache.c
@@ -134,7 +134,7 @@ static int policy_cache_new(X509 *x)
134 CERTIFICATEPOLICIES *ext_cpols = NULL; 134 CERTIFICATEPOLICIES *ext_cpols = NULL;
135 POLICY_MAPPINGS *ext_pmaps = NULL; 135 POLICY_MAPPINGS *ext_pmaps = NULL;
136 int i; 136 int i;
137 cache = OPENSSL_malloc(sizeof(X509_POLICY_CACHE)); 137 cache = malloc(sizeof(X509_POLICY_CACHE));
138 if (!cache) 138 if (!cache)
139 return 0; 139 return 0;
140 cache->anyPolicy = NULL; 140 cache->anyPolicy = NULL;
@@ -240,7 +240,7 @@ void policy_cache_free(X509_POLICY_CACHE *cache)
240 policy_data_free(cache->anyPolicy); 240 policy_data_free(cache->anyPolicy);
241 if (cache->data) 241 if (cache->data)
242 sk_X509_POLICY_DATA_pop_free(cache->data, policy_data_free); 242 sk_X509_POLICY_DATA_pop_free(cache->data, policy_data_free);
243 OPENSSL_free(cache); 243 free(cache);
244 } 244 }
245 245
246const X509_POLICY_CACHE *policy_cache_set(X509 *x) 246const X509_POLICY_CACHE *policy_cache_set(X509 *x)
diff --git a/src/lib/libcrypto/x509v3/pcy_data.c b/src/lib/libcrypto/x509v3/pcy_data.c
index 3444b03195..7c80915f5b 100644
--- a/src/lib/libcrypto/x509v3/pcy_data.c
+++ b/src/lib/libcrypto/x509v3/pcy_data.c
@@ -72,7 +72,7 @@ void policy_data_free(X509_POLICY_DATA *data)
72 sk_POLICYQUALINFO_pop_free(data->qualifier_set, 72 sk_POLICYQUALINFO_pop_free(data->qualifier_set,
73 POLICYQUALINFO_free); 73 POLICYQUALINFO_free);
74 sk_ASN1_OBJECT_pop_free(data->expected_policy_set, ASN1_OBJECT_free); 74 sk_ASN1_OBJECT_pop_free(data->expected_policy_set, ASN1_OBJECT_free);
75 OPENSSL_free(data); 75 free(data);
76 } 76 }
77 77
78/* Create a data based on an existing policy. If 'id' is NULL use the 78/* Create a data based on an existing policy. If 'id' is NULL use the
@@ -97,13 +97,13 @@ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
97 } 97 }
98 else 98 else
99 id = NULL; 99 id = NULL;
100 ret = OPENSSL_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 { 105 {
106 OPENSSL_free(ret); 106 free(ret);
107 if (id) 107 if (id)
108 ASN1_OBJECT_free(id); 108 ASN1_OBJECT_free(id);
109 return NULL; 109 return NULL;
diff --git a/src/lib/libcrypto/x509v3/pcy_node.c b/src/lib/libcrypto/x509v3/pcy_node.c
index bd1e7f1ae8..8c2124a7f6 100644
--- a/src/lib/libcrypto/x509v3/pcy_node.c
+++ b/src/lib/libcrypto/x509v3/pcy_node.c
@@ -115,7 +115,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
115 X509_POLICY_TREE *tree) 115 X509_POLICY_TREE *tree)
116 { 116 {
117 X509_POLICY_NODE *node; 117 X509_POLICY_NODE *node;
118 node = OPENSSL_malloc(sizeof(X509_POLICY_NODE)); 118 node = malloc(sizeof(X509_POLICY_NODE));
119 if (!node) 119 if (!node)
120 return NULL; 120 return NULL;
121 node->data = data; 121 node->data = data;
@@ -164,7 +164,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
164 164
165void policy_node_free(X509_POLICY_NODE *node) 165void policy_node_free(X509_POLICY_NODE *node)
166 { 166 {
167 OPENSSL_free(node); 167 free(node);
168 } 168 }
169 169
170/* See if a policy node matches a policy OID. If mapping enabled look through 170/* See if a policy node matches a policy OID. If mapping enabled look through
diff --git a/src/lib/libcrypto/x509v3/pcy_tree.c b/src/lib/libcrypto/x509v3/pcy_tree.c
index bb9777348f..c4239b1fd9 100644
--- a/src/lib/libcrypto/x509v3/pcy_tree.c
+++ b/src/lib/libcrypto/x509v3/pcy_tree.c
@@ -219,13 +219,13 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
219 219
220 /* If we get this far initialize the tree */ 220 /* If we get this far initialize the tree */
221 221
222 tree = OPENSSL_malloc(sizeof(X509_POLICY_TREE)); 222 tree = malloc(sizeof(X509_POLICY_TREE));
223 223
224 if (!tree) 224 if (!tree)
225 return 0; 225 return 0;
226 226
227 tree->flags = 0; 227 tree->flags = 0;
228 tree->levels = OPENSSL_malloc(sizeof(X509_POLICY_LEVEL) * n); 228 tree->levels = malloc(sizeof(X509_POLICY_LEVEL) * n);
229 tree->nlevel = 0; 229 tree->nlevel = 0;
230 tree->extra_data = NULL; 230 tree->extra_data = NULL;
231 tree->auth_policies = NULL; 231 tree->auth_policies = NULL;
@@ -233,7 +233,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
233 233
234 if (!tree->levels) 234 if (!tree->levels)
235 { 235 {
236 OPENSSL_free(tree); 236 free(tree);
237 return 0; 237 return 0;
238 } 238 }
239 239
@@ -516,7 +516,7 @@ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
516 if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK) 516 if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK)
517 { 517 {
518 node->parent->nchild--; 518 node->parent->nchild--;
519 OPENSSL_free(node); 519 free(node);
520 (void)sk_X509_POLICY_NODE_delete(nodes,i); 520 (void)sk_X509_POLICY_NODE_delete(nodes,i);
521 } 521 }
522 } 522 }
@@ -531,7 +531,7 @@ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
531 if (node->nchild == 0) 531 if (node->nchild == 0)
532 { 532 {
533 node->parent->nchild--; 533 node->parent->nchild--;
534 OPENSSL_free(node); 534 free(node);
535 (void)sk_X509_POLICY_NODE_delete(nodes, i); 535 (void)sk_X509_POLICY_NODE_delete(nodes, i);
536 } 536 }
537 } 537 }
@@ -539,7 +539,7 @@ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
539 { 539 {
540 if (curr->anyPolicy->parent) 540 if (curr->anyPolicy->parent)
541 curr->anyPolicy->parent->nchild--; 541 curr->anyPolicy->parent->nchild--;
542 OPENSSL_free(curr->anyPolicy); 542 free(curr->anyPolicy);
543 curr->anyPolicy = NULL; 543 curr->anyPolicy = NULL;
544 } 544 }
545 if (curr == tree->levels) 545 if (curr == tree->levels)
@@ -721,7 +721,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
721static void exnode_free(X509_POLICY_NODE *node) 721static void exnode_free(X509_POLICY_NODE *node)
722 { 722 {
723 if (node->data && (node->data->flags & POLICY_DATA_FLAG_EXTRA_NODE)) 723 if (node->data && (node->data->flags & POLICY_DATA_FLAG_EXTRA_NODE))
724 OPENSSL_free(node); 724 free(node);
725 } 725 }
726 726
727 727
@@ -751,8 +751,8 @@ void X509_policy_tree_free(X509_POLICY_TREE *tree)
751 sk_X509_POLICY_DATA_pop_free(tree->extra_data, 751 sk_X509_POLICY_DATA_pop_free(tree->extra_data,
752 policy_data_free); 752 policy_data_free);
753 753
754 OPENSSL_free(tree->levels); 754 free(tree->levels);
755 OPENSSL_free(tree); 755 free(tree);
756 756
757 } 757 }
758 758
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
index df46a4983b..179f08d222 100644
--- a/src/lib/libcrypto/x509v3/v3_addr.c
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -1013,7 +1013,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
1013 X509V3_conf_err(val); 1013 X509V3_conf_err(val);
1014 goto err; 1014 goto err;
1015 } 1015 }
1016 OPENSSL_free(s); 1016 free(s);
1017 s = NULL; 1017 s = NULL;
1018 continue; 1018 continue;
1019 } 1019 }
@@ -1077,7 +1077,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
1077 goto err; 1077 goto err;
1078 } 1078 }
1079 1079
1080 OPENSSL_free(s); 1080 free(s);
1081 s = NULL; 1081 s = NULL;
1082 } 1082 }
1083 1083
@@ -1089,7 +1089,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
1089 return addr; 1089 return addr;
1090 1090
1091 err: 1091 err:
1092 OPENSSL_free(s); 1092 free(s);
1093 sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free); 1093 sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free);
1094 return NULL; 1094 return NULL;
1095} 1095}
diff --git a/src/lib/libcrypto/x509v3/v3_akey.c b/src/lib/libcrypto/x509v3/v3_akey.c
index c6b68ee221..04e1fb9544 100644
--- a/src/lib/libcrypto/x509v3/v3_akey.c
+++ b/src/lib/libcrypto/x509v3/v3_akey.c
@@ -87,7 +87,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
87 if(akeyid->keyid) { 87 if(akeyid->keyid) {
88 tmp = hex_to_string(akeyid->keyid->data, akeyid->keyid->length); 88 tmp = hex_to_string(akeyid->keyid->data, akeyid->keyid->length);
89 X509V3_add_value("keyid", tmp, &extlist); 89 X509V3_add_value("keyid", tmp, &extlist);
90 OPENSSL_free(tmp); 90 free(tmp);
91 } 91 }
92 if(akeyid->issuer) 92 if(akeyid->issuer)
93 extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); 93 extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist);
@@ -95,7 +95,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
95 tmp = hex_to_string(akeyid->serial->data, 95 tmp = hex_to_string(akeyid->serial->data,
96 akeyid->serial->length); 96 akeyid->serial->length);
97 X509V3_add_value("serial", tmp, &extlist); 97 X509V3_add_value("serial", tmp, &extlist);
98 OPENSSL_free(tmp); 98 free(tmp);
99 } 99 }
100 return extlist; 100 return extlist;
101} 101}
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index 8de5dd041b..636677df94 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -578,11 +578,11 @@ static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx)
578 if (!(gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx))) 578 if (!(gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)))
579 return 0; 579 return 0;
580 objlen = p - value; 580 objlen = p - value;
581 objtmp = OPENSSL_malloc(objlen + 1); 581 objtmp = malloc(objlen + 1);
582 if (objtmp) { 582 if (objtmp) {
583 strlcpy(objtmp, value, objlen + 1); 583 strlcpy(objtmp, value, objlen + 1);
584 gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0); 584 gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0);
585 OPENSSL_free(objtmp); 585 free(objtmp);
586 } else 586 } else
587 gen->d.otherName->type_id = NULL; 587 gen->d.otherName->type_id = NULL;
588 if (!gen->d.otherName->type_id) 588 if (!gen->d.otherName->type_id)
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c
index 1587e8ed72..325c8e0406 100644
--- a/src/lib/libcrypto/x509v3/v3_asid.c
+++ b/src/lib/libcrypto/x509v3/v3_asid.c
@@ -125,17 +125,17 @@ static int i2r_ASIdentifierChoice(BIO *out,
125 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.id)) == NULL) 125 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.id)) == NULL)
126 return 0; 126 return 0;
127 BIO_printf(out, "%*s%s\n", indent + 2, "", s); 127 BIO_printf(out, "%*s%s\n", indent + 2, "", s);
128 OPENSSL_free(s); 128 free(s);
129 break; 129 break;
130 case ASIdOrRange_range: 130 case ASIdOrRange_range:
131 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->min)) == NULL) 131 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->min)) == NULL)
132 return 0; 132 return 0;
133 BIO_printf(out, "%*s%s-", indent + 2, "", s); 133 BIO_printf(out, "%*s%s-", indent + 2, "", s);
134 OPENSSL_free(s); 134 free(s);
135 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->max)) == NULL) 135 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->max)) == NULL)
136 return 0; 136 return 0;
137 BIO_printf(out, "%s\n", s); 137 BIO_printf(out, "%s\n", s);
138 OPENSSL_free(s); 138 free(s);
139 break; 139 break;
140 default: 140 default:
141 return 0; 141 return 0;
@@ -471,7 +471,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
471 ASRange *r; 471 ASRange *r;
472 switch (a->type) { 472 switch (a->type) {
473 case ASIdOrRange_id: 473 case ASIdOrRange_id:
474 if ((r = OPENSSL_malloc(sizeof(ASRange))) == NULL) { 474 if ((r = malloc(sizeof(ASRange))) == NULL) {
475 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, 475 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
476 ERR_R_MALLOC_FAILURE); 476 ERR_R_MALLOC_FAILURE);
477 goto done; 477 goto done;
@@ -620,7 +620,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
620 s[i1] = '\0'; 620 s[i1] = '\0';
621 min = s2i_ASN1_INTEGER(NULL, s); 621 min = s2i_ASN1_INTEGER(NULL, s);
622 max = s2i_ASN1_INTEGER(NULL, s + i2); 622 max = s2i_ASN1_INTEGER(NULL, s + i2);
623 OPENSSL_free(s); 623 free(s);
624 if (min == NULL || max == NULL) { 624 if (min == NULL || max == NULL) {
625 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); 625 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
626 goto err; 626 goto err;
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c
index 6730f9a6ee..519aefc93c 100644
--- a/src/lib/libcrypto/x509v3/v3_conf.c
+++ b/src/lib/libcrypto/x509v3/v3_conf.c
@@ -190,7 +190,7 @@ static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid,
190 { 190 {
191 unsigned char *p; 191 unsigned char *p;
192 ext_len = method->i2d(ext_struc, NULL); 192 ext_len = method->i2d(ext_struc, NULL);
193 if(!(ext_der = OPENSSL_malloc(ext_len))) goto merr; 193 if(!(ext_der = malloc(ext_len))) goto merr;
194 p = ext_der; 194 p = ext_der;
195 method->i2d(ext_struc, &p); 195 method->i2d(ext_struc, &p);
196 } 196 }
@@ -300,7 +300,7 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
300 err: 300 err:
301 ASN1_OBJECT_free(obj); 301 ASN1_OBJECT_free(obj);
302 M_ASN1_OCTET_STRING_free(oct); 302 M_ASN1_OCTET_STRING_free(oct);
303 if(ext_der) OPENSSL_free(ext_der); 303 if(ext_der) free(ext_der);
304 return extension; 304 return extension;
305 305
306 } 306 }
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c
index 1f0798b946..1a337fa07e 100644
--- a/src/lib/libcrypto/x509v3/v3_cpols.c
+++ b/src/lib/libcrypto/x509v3/v3_cpols.c
@@ -426,7 +426,7 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent)
426 if(i) BIO_puts(out, ", "); 426 if(i) BIO_puts(out, ", ");
427 tmp = i2s_ASN1_INTEGER(NULL, num); 427 tmp = i2s_ASN1_INTEGER(NULL, num);
428 BIO_puts(out, tmp); 428 BIO_puts(out, tmp);
429 OPENSSL_free(tmp); 429 free(tmp);
430 } 430 }
431 BIO_puts(out, "\n"); 431 BIO_puts(out, "\n");
432 } 432 }
diff --git a/src/lib/libcrypto/x509v3/v3_ia5.c b/src/lib/libcrypto/x509v3/v3_ia5.c
index ab1c5188b8..98789b36e9 100644
--- a/src/lib/libcrypto/x509v3/v3_ia5.c
+++ b/src/lib/libcrypto/x509v3/v3_ia5.c
@@ -82,7 +82,7 @@ static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
82{ 82{
83 char *tmp; 83 char *tmp;
84 if(!ia5 || !ia5->length) return NULL; 84 if(!ia5 || !ia5->length) return NULL;
85 if(!(tmp = OPENSSL_malloc(ia5->length + 1))) { 85 if(!(tmp = malloc(ia5->length + 1))) {
86 X509V3err(X509V3_F_I2S_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); 86 X509V3err(X509V3_F_I2S_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE);
87 return NULL; 87 return NULL;
88 } 88 }
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
index 44bc3e1105..2b290ca00c 100644
--- a/src/lib/libcrypto/x509v3/v3_info.c
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -115,7 +115,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
115 vtmp = sk_CONF_VALUE_value(ret, i); 115 vtmp = sk_CONF_VALUE_value(ret, i);
116 i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method); 116 i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method);
117 nlen = strlen(objtmp) + strlen(vtmp->name) + 5; 117 nlen = strlen(objtmp) + strlen(vtmp->name) + 5;
118 ntmp = OPENSSL_malloc(nlen); 118 ntmp = malloc(nlen);
119 if(!ntmp) { 119 if(!ntmp) {
120 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, 120 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
121 ERR_R_MALLOC_FAILURE); 121 ERR_R_MALLOC_FAILURE);
@@ -124,7 +124,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
124 BUF_strlcpy(ntmp, objtmp, nlen); 124 BUF_strlcpy(ntmp, objtmp, nlen);
125 BUF_strlcat(ntmp, " - ", nlen); 125 BUF_strlcat(ntmp, " - ", nlen);
126 BUF_strlcat(ntmp, vtmp->name, nlen); 126 BUF_strlcat(ntmp, vtmp->name, nlen);
127 OPENSSL_free(vtmp->name); 127 free(vtmp->name);
128 vtmp->name = ntmp; 128 vtmp->name = ntmp;
129 129
130 } 130 }
@@ -161,7 +161,7 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *metho
161 ctmp.value = cnf->value; 161 ctmp.value = cnf->value;
162 if(!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0)) 162 if(!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
163 goto err; 163 goto err;
164 if(!(objtmp = OPENSSL_malloc(objlen + 1))) { 164 if(!(objtmp = malloc(objlen + 1))) {
165 X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE); 165 X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,ERR_R_MALLOC_FAILURE);
166 goto err; 166 goto err;
167 } 167 }
@@ -170,10 +170,10 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *metho
170 if(!acc->method) { 170 if(!acc->method) {
171 X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT); 171 X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,X509V3_R_BAD_OBJECT);
172 ERR_add_error_data(2, "value=", objtmp); 172 ERR_add_error_data(2, "value=", objtmp);
173 OPENSSL_free(objtmp); 173 free(objtmp);
174 goto err; 174 goto err;
175 } 175 }
176 OPENSSL_free(objtmp); 176 free(objtmp);
177 177
178 } 178 }
179 return ainfo; 179 return ainfo;
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index 0f1e1d4422..0613ea7f22 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -133,7 +133,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from)
133 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,X509V3_R_EXTENSION_NOT_FOUND); 133 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,X509V3_R_EXTENSION_NOT_FOUND);
134 return 0; 134 return 0;
135 } 135 }
136 if(!(tmpext = (X509V3_EXT_METHOD *)OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) { 136 if(!(tmpext = (X509V3_EXT_METHOD *)malloc(sizeof(X509V3_EXT_METHOD)))) {
137 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,ERR_R_MALLOC_FAILURE); 137 X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,ERR_R_MALLOC_FAILURE);
138 return 0; 138 return 0;
139 } 139 }
@@ -151,7 +151,7 @@ void X509V3_EXT_cleanup(void)
151 151
152static void ext_list_free(X509V3_EXT_METHOD *ext) 152static void ext_list_free(X509V3_EXT_METHOD *ext)
153{ 153{
154 if(ext->ext_flags & X509V3_EXT_DYNAMIC) OPENSSL_free(ext); 154 if(ext->ext_flags & X509V3_EXT_DYNAMIC) free(ext);
155} 155}
156 156
157/* Legacy function: we don't need to add standard extensions 157/* Legacy function: we don't need to add standard extensions
diff --git a/src/lib/libcrypto/x509v3/v3_pci.c b/src/lib/libcrypto/x509v3/v3_pci.c
index 0dcfa004fe..9cef94258c 100644
--- a/src/lib/libcrypto/x509v3/v3_pci.c
+++ b/src/lib/libcrypto/x509v3/v3_pci.c
@@ -135,7 +135,7 @@ static int process_pci_value(CONF_VALUE *val,
135 goto err; 135 goto err;
136 } 136 }
137 137
138 tmp_data = OPENSSL_realloc((*policy)->data, 138 tmp_data = realloc((*policy)->data,
139 (*policy)->length + val_len + 1); 139 (*policy)->length + val_len + 1);
140 if (tmp_data) 140 if (tmp_data)
141 { 141 {
@@ -147,7 +147,7 @@ static int process_pci_value(CONF_VALUE *val,
147 } 147 }
148 else 148 else
149 { 149 {
150 OPENSSL_free(tmp_data2); 150 free(tmp_data2);
151 /* realloc failure implies the original data space is b0rked too! */ 151 /* realloc failure implies the original data space is b0rked too! */
152 (*policy)->data = NULL; 152 (*policy)->data = NULL;
153 (*policy)->length = 0; 153 (*policy)->length = 0;
@@ -155,7 +155,7 @@ static int process_pci_value(CONF_VALUE *val,
155 X509V3_conf_err(val); 155 X509V3_conf_err(val);
156 goto err; 156 goto err;
157 } 157 }
158 OPENSSL_free(tmp_data2); 158 free(tmp_data2);
159 } 159 }
160 else if (strncmp(val->value, "file:", 5) == 0) 160 else if (strncmp(val->value, "file:", 5) == 0)
161 { 161 {
@@ -173,7 +173,7 @@ static int process_pci_value(CONF_VALUE *val,
173 { 173 {
174 if (!n) continue; 174 if (!n) continue;
175 175
176 tmp_data = OPENSSL_realloc((*policy)->data, 176 tmp_data = realloc((*policy)->data,
177 (*policy)->length + n + 1); 177 (*policy)->length + n + 1);
178 178
179 if (!tmp_data) 179 if (!tmp_data)
@@ -197,7 +197,7 @@ static int process_pci_value(CONF_VALUE *val,
197 else if (strncmp(val->value, "text:", 5) == 0) 197 else if (strncmp(val->value, "text:", 5) == 0)
198 { 198 {
199 val_len = strlen(val->value + 5); 199 val_len = strlen(val->value + 5);
200 tmp_data = OPENSSL_realloc((*policy)->data, 200 tmp_data = realloc((*policy)->data,
201 (*policy)->length + val_len + 1); 201 (*policy)->length + val_len + 1);
202 if (tmp_data) 202 if (tmp_data)
203 { 203 {
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index 2124b447b4..565937af47 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -126,7 +126,7 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int inde
126 126
127 err: 127 err:
128 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); 128 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
129 if(value) OPENSSL_free(value); 129 if(value) free(value);
130 if(method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); 130 if(method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it));
131 else method->ext_free(ext_str); 131 else method->ext_free(ext_str);
132 return ok; 132 return ok;
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index f59bfc1844..45d7251c29 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -183,17 +183,17 @@ int X509_PURPOSE_add(int id, int trust, int flags,
183 idx = X509_PURPOSE_get_by_id(id); 183 idx = X509_PURPOSE_get_by_id(id);
184 /* Need a new entry */ 184 /* Need a new entry */
185 if(idx == -1) { 185 if(idx == -1) {
186 if(!(ptmp = OPENSSL_malloc(sizeof(X509_PURPOSE)))) { 186 if(!(ptmp = malloc(sizeof(X509_PURPOSE)))) {
187 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE); 187 X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE);
188 return 0; 188 return 0;
189 } 189 }
190 ptmp->flags = X509_PURPOSE_DYNAMIC; 190 ptmp->flags = X509_PURPOSE_DYNAMIC;
191 } else ptmp = X509_PURPOSE_get0(idx); 191 } else ptmp = X509_PURPOSE_get0(idx);
192 192
193 /* OPENSSL_free existing name if dynamic */ 193 /* free existing name if dynamic */
194 if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) { 194 if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
195 OPENSSL_free(ptmp->name); 195 free(ptmp->name);
196 OPENSSL_free(ptmp->sname); 196 free(ptmp->sname);
197 } 197 }
198 /* dup supplied name */ 198 /* dup supplied name */
199 ptmp->name = BUF_strdup(name); 199 ptmp->name = BUF_strdup(name);
@@ -232,10 +232,10 @@ static void xptable_free(X509_PURPOSE *p)
232 if (p->flags & X509_PURPOSE_DYNAMIC) 232 if (p->flags & X509_PURPOSE_DYNAMIC)
233 { 233 {
234 if (p->flags & X509_PURPOSE_DYNAMIC_NAME) { 234 if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
235 OPENSSL_free(p->name); 235 free(p->name);
236 OPENSSL_free(p->sname); 236 free(p->sname);
237 } 237 }
238 OPENSSL_free(p); 238 free(p);
239 } 239 }
240 } 240 }
241 241
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c
index 2a6bf11b65..a2b0322e44 100644
--- a/src/lib/libcrypto/x509v3/v3_sxnet.c
+++ b/src/lib/libcrypto/x509v3/v3_sxnet.c
@@ -114,7 +114,7 @@ static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out,
114 id = sk_SXNETID_value(sx->ids, i); 114 id = sk_SXNETID_value(sx->ids, i);
115 tmp = i2s_ASN1_INTEGER(NULL, id->zone); 115 tmp = i2s_ASN1_INTEGER(NULL, id->zone);
116 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp); 116 BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp);
117 OPENSSL_free(tmp); 117 free(tmp);
118 M_ASN1_OCTET_STRING_print(out, id->user); 118 M_ASN1_OCTET_STRING_print(out, id->user);
119 } 119 }
120 return 1; 120 return 1;
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index c4b6143eff..d938a175ed 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -85,7 +85,7 @@ int X509V3_add_value(const char *name, const char *value,
85 char *tname = NULL, *tvalue = NULL; 85 char *tname = NULL, *tvalue = NULL;
86 if(name && !(tname = BUF_strdup(name))) goto err; 86 if(name && !(tname = BUF_strdup(name))) goto err;
87 if(value && !(tvalue = BUF_strdup(value))) goto err; 87 if(value && !(tvalue = BUF_strdup(value))) goto err;
88 if(!(vtmp = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) goto err; 88 if(!(vtmp = (CONF_VALUE *)malloc(sizeof(CONF_VALUE)))) goto err;
89 if(!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) goto err; 89 if(!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) goto err;
90 vtmp->section = NULL; 90 vtmp->section = NULL;
91 vtmp->name = tname; 91 vtmp->name = tname;
@@ -94,9 +94,9 @@ int X509V3_add_value(const char *name, const char *value,
94 return 1; 94 return 1;
95 err: 95 err:
96 X509V3err(X509V3_F_X509V3_ADD_VALUE,ERR_R_MALLOC_FAILURE); 96 X509V3err(X509V3_F_X509V3_ADD_VALUE,ERR_R_MALLOC_FAILURE);
97 if(vtmp) OPENSSL_free(vtmp); 97 if(vtmp) free(vtmp);
98 if(tname) OPENSSL_free(tname); 98 if(tname) free(tname);
99 if(tvalue) OPENSSL_free(tvalue); 99 if(tvalue) free(tvalue);
100 return 0; 100 return 0;
101} 101}
102 102
@@ -111,10 +111,10 @@ int X509V3_add_value_uchar(const char *name, const unsigned char *value,
111void X509V3_conf_free(CONF_VALUE *conf) 111void X509V3_conf_free(CONF_VALUE *conf)
112{ 112{
113 if(!conf) return; 113 if(!conf) return;
114 if(conf->name) OPENSSL_free(conf->name); 114 if(conf->name) free(conf->name);
115 if(conf->value) OPENSSL_free(conf->value); 115 if(conf->value) free(conf->value);
116 if(conf->section) OPENSSL_free(conf->section); 116 if(conf->section) free(conf->section);
117 OPENSSL_free(conf); 117 free(conf);
118} 118}
119 119
120int X509V3_add_value_bool(const char *name, int asn1_bool, 120int X509V3_add_value_bool(const char *name, int asn1_bool,
@@ -206,7 +206,7 @@ int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,
206 if(!aint) return 1; 206 if(!aint) return 1;
207 if(!(strtmp = i2s_ASN1_INTEGER(NULL, aint))) return 0; 207 if(!(strtmp = i2s_ASN1_INTEGER(NULL, aint))) return 0;
208 ret = X509V3_add_value(name, strtmp, extlist); 208 ret = X509V3_add_value(name, strtmp, extlist);
209 OPENSSL_free(strtmp); 209 free(strtmp);
210 return ret; 210 return ret;
211} 211}
212 212
@@ -328,11 +328,11 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
328 } 328 }
329 X509V3_add_value(ntmp, NULL, &values); 329 X509V3_add_value(ntmp, NULL, &values);
330 } 330 }
331OPENSSL_free(linebuf); 331free(linebuf);
332return values; 332return values;
333 333
334err: 334err:
335OPENSSL_free(linebuf); 335free(linebuf);
336sk_CONF_VALUE_pop_free(values, X509V3_conf_free); 336sk_CONF_VALUE_pop_free(values, X509V3_conf_free);
337return NULL; 337return NULL;
338 338
@@ -355,7 +355,7 @@ static char *strip_spaces(char *name)
355 355
356/* hex string utilities */ 356/* hex string utilities */
357 357
358/* Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its 358/* Given a buffer of length 'len' return a malloc'ed string with its
359 * hex representation 359 * hex representation
360 * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) 360 * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines)
361 */ 361 */
@@ -367,7 +367,7 @@ char *hex_to_string(const unsigned char *buffer, long len)
367 int i; 367 int i;
368 const static char hexdig[] = "0123456789ABCDEF"; 368 const static char hexdig[] = "0123456789ABCDEF";
369 if(!buffer || !len) return NULL; 369 if(!buffer || !len) return NULL;
370 if(!(tmp = OPENSSL_malloc(len * 3 + 1))) { 370 if(!(tmp = malloc(len * 3 + 1))) {
371 X509V3err(X509V3_F_HEX_TO_STRING,ERR_R_MALLOC_FAILURE); 371 X509V3err(X509V3_F_HEX_TO_STRING,ERR_R_MALLOC_FAILURE);
372 return NULL; 372 return NULL;
373 } 373 }
@@ -393,14 +393,14 @@ unsigned char *string_to_hex(const char *str, long *len)
393 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_INVALID_NULL_ARGUMENT); 393 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_INVALID_NULL_ARGUMENT);
394 return NULL; 394 return NULL;
395 } 395 }
396 if(!(hexbuf = OPENSSL_malloc(strlen(str) >> 1))) goto err; 396 if(!(hexbuf = malloc(strlen(str) >> 1))) goto err;
397 for(p = (unsigned char *)str, q = hexbuf; *p;) { 397 for(p = (unsigned char *)str, q = hexbuf; *p;) {
398 ch = *p++; 398 ch = *p++;
399 if(ch == ':') continue; 399 if(ch == ':') continue;
400 cl = *p++; 400 cl = *p++;
401 if(!cl) { 401 if(!cl) {
402 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ODD_NUMBER_OF_DIGITS); 402 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ODD_NUMBER_OF_DIGITS);
403 OPENSSL_free(hexbuf); 403 free(hexbuf);
404 return NULL; 404 return NULL;
405 } 405 }
406 if(isupper(ch)) ch = tolower(ch); 406 if(isupper(ch)) ch = tolower(ch);
@@ -422,12 +422,12 @@ unsigned char *string_to_hex(const char *str, long *len)
422 return hexbuf; 422 return hexbuf;
423 423
424 err: 424 err:
425 if(hexbuf) OPENSSL_free(hexbuf); 425 if(hexbuf) free(hexbuf);
426 X509V3err(X509V3_F_STRING_TO_HEX,ERR_R_MALLOC_FAILURE); 426 X509V3err(X509V3_F_STRING_TO_HEX,ERR_R_MALLOC_FAILURE);
427 return NULL; 427 return NULL;
428 428
429 badhex: 429 badhex:
430 OPENSSL_free(hexbuf); 430 free(hexbuf);
431 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ILLEGAL_HEX_DIGIT); 431 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ILLEGAL_HEX_DIGIT);
432 return NULL; 432 return NULL;
433 433
@@ -531,7 +531,7 @@ static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens)
531 531
532static void str_free(OPENSSL_STRING str) 532static void str_free(OPENSSL_STRING str)
533{ 533{
534 OPENSSL_free(str); 534 free(str);
535} 535}
536 536
537static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email) 537static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
@@ -608,7 +608,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
608 608
609 iplen2 = a2i_ipadd(ipout + iplen1, p); 609 iplen2 = a2i_ipadd(ipout + iplen1, p);
610 610
611 OPENSSL_free(iptmp); 611 free(iptmp);
612 iptmp = NULL; 612 iptmp = NULL;
613 613
614 if (!iplen2 || (iplen1 != iplen2)) 614 if (!iplen2 || (iplen1 != iplen2))
@@ -624,7 +624,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
624 624
625 err: 625 err:
626 if (iptmp) 626 if (iptmp)
627 OPENSSL_free(iptmp); 627 free(iptmp);
628 if (ret) 628 if (ret)
629 ASN1_OCTET_STRING_free(ret); 629 ASN1_OCTET_STRING_free(ret);
630 return NULL; 630 return NULL;