summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1
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/asn1
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/asn1')
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c6
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c14
-rw-r--r--src/lib/libcrypto/asn1/a_digest.c2
-rw-r--r--src/lib/libcrypto/asn1/a_dup.c6
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c6
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c4
-rw-r--r--src/lib/libcrypto/asn1/a_i2d_fp.c6
-rw-r--r--src/lib/libcrypto/asn1/a_int.c18
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_object.c26
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c8
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c4
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c4
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c4
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c2
-rw-r--r--src/lib/libcrypto/asn1/ameth_lib.c8
-rw-r--r--src/lib/libcrypto/asn1/asn1_gen.c8
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c12
-rw-r--r--src/lib/libcrypto/asn1/asn1_mac.h2
-rw-r--r--src/lib/libcrypto/asn1/asn_mime.c18
-rw-r--r--src/lib/libcrypto/asn1/asn_moid.c2
-rw-r--r--src/lib/libcrypto/asn1/asn_pack.c2
-rw-r--r--src/lib/libcrypto/asn1/bio_asn1.c8
-rw-r--r--src/lib/libcrypto/asn1/bio_ndef.c12
-rw-r--r--src/lib/libcrypto/asn1/f_enum.c6
-rw-r--r--src/lib/libcrypto/asn1/f_int.c4
-rw-r--r--src/lib/libcrypto/asn1/f_string.c6
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c4
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c2
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c2
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c12
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c10
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c6
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c6
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c6
-rw-r--r--src/lib/libcrypto/asn1/tasn_utl.c6
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c4
-rw-r--r--src/lib/libcrypto/asn1/x_info.c6
-rw-r--r--src/lib/libcrypto/asn1/x_name.c12
-rw-r--r--src/lib/libcrypto/asn1/x_pkey.c4
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c2
-rw-r--r--src/lib/libcrypto/asn1/x_x509.c4
43 files changed, 146 insertions, 146 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 34179960b8..e2b65bf2ac 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -144,7 +144,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
144 144
145 if (len-- > 1) /* using one because of the bits left byte */ 145 if (len-- > 1) /* using one because of the bits left byte */
146 { 146 {
147 s=(unsigned char *)OPENSSL_malloc((int)len); 147 s=(unsigned char *)malloc((int)len);
148 if (s == NULL) 148 if (s == NULL)
149 { 149 {
150 i=ERR_R_MALLOC_FAILURE; 150 i=ERR_R_MALLOC_FAILURE;
@@ -158,7 +158,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
158 s=NULL; 158 s=NULL;
159 159
160 ret->length=(int)len; 160 ret->length=(int)len;
161 if (ret->data != NULL) OPENSSL_free(ret->data); 161 if (ret->data != NULL) free(ret->data);
162 ret->data=s; 162 ret->data=s;
163 ret->type=V_ASN1_BIT_STRING; 163 ret->type=V_ASN1_BIT_STRING;
164 if (a != NULL) (*a)=ret; 164 if (a != NULL) (*a)=ret;
@@ -192,7 +192,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
192 { 192 {
193 if (!value) return(1); /* Don't need to set */ 193 if (!value) return(1); /* Don't need to set */
194 if (a->data == NULL) 194 if (a->data == NULL)
195 c=(unsigned char *)OPENSSL_malloc(w+1); 195 c=(unsigned char *)malloc(w+1);
196 else 196 else
197 c=(unsigned char *)OPENSSL_realloc_clean(a->data, 197 c=(unsigned char *)OPENSSL_realloc_clean(a->data,
198 a->length, 198 a->length,
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index 92d630cdba..8431d89edf 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -101,7 +101,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
101 101
102 if (len != 0) 102 if (len != 0)
103 { 103 {
104 s=(unsigned char *)OPENSSL_malloc((int)len+1); 104 s=(unsigned char *)malloc((int)len+1);
105 if (s == NULL) 105 if (s == NULL)
106 { 106 {
107 i=ERR_R_MALLOC_FAILURE; 107 i=ERR_R_MALLOC_FAILURE;
@@ -114,7 +114,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
114 else 114 else
115 s=NULL; 115 s=NULL;
116 116
117 if (ret->data != NULL) OPENSSL_free(ret->data); 117 if (ret->data != NULL) free(ret->data);
118 ret->length=(int)len; 118 ret->length=(int)len;
119 ret->data=s; 119 ret->data=s;
120 ret->type=tag; 120 ret->type=tag;
@@ -209,8 +209,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
209 { 209 {
210 if ((ret->length < len) || (ret->data == NULL)) 210 if ((ret->length < len) || (ret->data == NULL))
211 { 211 {
212 if (ret->data != NULL) OPENSSL_free(ret->data); 212 if (ret->data != NULL) free(ret->data);
213 s=(unsigned char *)OPENSSL_malloc((int)len + 1); 213 s=(unsigned char *)malloc((int)len + 1);
214 if (s == NULL) 214 if (s == NULL)
215 { 215 {
216 i=ERR_R_MALLOC_FAILURE; 216 i=ERR_R_MALLOC_FAILURE;
@@ -226,7 +226,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
226 else 226 else
227 { 227 {
228 s=NULL; 228 s=NULL;
229 if (ret->data != NULL) OPENSSL_free(ret->data); 229 if (ret->data != NULL) free(ret->data);
230 } 230 }
231 231
232 ret->length=(int)len; 232 ret->length=(int)len;
@@ -301,14 +301,14 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c)
301 if (!asn1_const_Finish(c)) goto err; 301 if (!asn1_const_Finish(c)) goto err;
302 302
303 a->length=num; 303 a->length=num;
304 if (a->data != NULL) OPENSSL_free(a->data); 304 if (a->data != NULL) free(a->data);
305 a->data=(unsigned char *)b.data; 305 a->data=(unsigned char *)b.data;
306 if (os != NULL) ASN1_STRING_free(os); 306 if (os != NULL) ASN1_STRING_free(os);
307 return(1); 307 return(1);
308err: 308err:
309 ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error); 309 ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error);
310 if (os != NULL) ASN1_STRING_free(os); 310 if (os != NULL) ASN1_STRING_free(os);
311 if (b.data != NULL) OPENSSL_free(b.data); 311 if (b.data != NULL) free(b.data);
312 return(0); 312 return(0);
313 } 313 }
314 314
diff --git a/src/lib/libcrypto/asn1/a_digest.c b/src/lib/libcrypto/asn1/a_digest.c
index 8a4b24a06b..0d463d409b 100644
--- a/src/lib/libcrypto/asn1/a_digest.c
+++ b/src/lib/libcrypto/asn1/a_digest.c
@@ -81,6 +81,6 @@ int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
81 81
82 if (!EVP_Digest(str, i, md, len, type, NULL)) 82 if (!EVP_Digest(str, i, md, len, type, NULL))
83 return 0; 83 return 0;
84 OPENSSL_free(str); 84 free(str);
85 return(1); 85 return(1);
86 } 86 }
diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c
index d98992548a..e825b9c2d4 100644
--- a/src/lib/libcrypto/asn1/a_dup.c
+++ b/src/lib/libcrypto/asn1/a_dup.c
@@ -72,14 +72,14 @@ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
72 if (x == NULL) return(NULL); 72 if (x == NULL) return(NULL);
73 73
74 i=i2d(x,NULL); 74 i=i2d(x,NULL);
75 b=OPENSSL_malloc(i+10); 75 b=malloc(i+10);
76 if (b == NULL) 76 if (b == NULL)
77 { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); } 77 { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
78 p= b; 78 p= b;
79 i=i2d(x,&p); 79 i=i2d(x,&p);
80 p2= b; 80 p2= b;
81 ret=d2i(NULL,&p2,i); 81 ret=d2i(NULL,&p2,i);
82 OPENSSL_free(b); 82 free(b);
83 return(ret); 83 return(ret);
84 } 84 }
85 85
@@ -104,6 +104,6 @@ void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
104 { ASN1err(ASN1_F_ASN1_ITEM_DUP,ERR_R_MALLOC_FAILURE); return(NULL); } 104 { ASN1err(ASN1_F_ASN1_ITEM_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
105 p= b; 105 p= b;
106 ret=ASN1_item_d2i(NULL,&p,i, it); 106 ret=ASN1_item_d2i(NULL,&p,i, it);
107 OPENSSL_free(b); 107 free(b);
108 return(ret); 108 return(ret);
109 } 109 }
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index fe9aa13b9c..c1154dde0a 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -77,8 +77,8 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
77 if (a->length < (int)(sizeof(long)+1)) 77 if (a->length < (int)(sizeof(long)+1))
78 { 78 {
79 if (a->data != NULL) 79 if (a->data != NULL)
80 OPENSSL_free(a->data); 80 free(a->data);
81 if ((a->data=(unsigned char *)OPENSSL_malloc(sizeof(long)+1)) != NULL) 81 if ((a->data=(unsigned char *)malloc(sizeof(long)+1)) != NULL)
82 memset((char *)a->data,0,sizeof(long)+1); 82 memset((char *)a->data,0,sizeof(long)+1);
83 } 83 }
84 if (a->data == NULL) 84 if (a->data == NULL)
@@ -155,7 +155,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
155 len=((j == 0)?0:((j/8)+1)); 155 len=((j == 0)?0:((j/8)+1));
156 if (ret->length < len+4) 156 if (ret->length < len+4)
157 { 157 {
158 unsigned char *new_data=OPENSSL_realloc(ret->data, len+4); 158 unsigned char *new_data=realloc(ret->data, len+4);
159 if (!new_data) 159 if (!new_data)
160 { 160 {
161 ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); 161 ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index 4f312ee6c9..86666e7a20 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -225,7 +225,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
225 p=(char *)s->data; 225 p=(char *)s->data;
226 if ((p == NULL) || ((size_t)s->length < len)) 226 if ((p == NULL) || ((size_t)s->length < len))
227 { 227 {
228 p=OPENSSL_malloc(len); 228 p=malloc(len);
229 if (p == NULL) 229 if (p == NULL)
230 { 230 {
231 ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, 231 ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ,
@@ -233,7 +233,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
233 return(NULL); 233 return(NULL);
234 } 234 }
235 if (s->data != NULL) 235 if (s->data != NULL)
236 OPENSSL_free(s->data); 236 free(s->data);
237 s->data=(unsigned char *)p; 237 s->data=(unsigned char *)p;
238 } 238 }
239 239
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c
index a3ad76d356..484bcd66eb 100644
--- a/src/lib/libcrypto/asn1/a_i2d_fp.c
+++ b/src/lib/libcrypto/asn1/a_i2d_fp.c
@@ -88,7 +88,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
88 int i,j=0,n,ret=1; 88 int i,j=0,n,ret=1;
89 89
90 n=i2d(x,NULL); 90 n=i2d(x,NULL);
91 b=(char *)OPENSSL_malloc(n); 91 b=(char *)malloc(n);
92 if (b == NULL) 92 if (b == NULL)
93 { 93 {
94 ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE); 94 ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE);
@@ -110,7 +110,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
110 j+=i; 110 j+=i;
111 n-=i; 111 n-=i;
112 } 112 }
113 OPENSSL_free(b); 113 free(b);
114 return(ret); 114 return(ret);
115 } 115 }
116 116
@@ -158,6 +158,6 @@ int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
158 j+=i; 158 j+=i;
159 n-=i; 159 n-=i;
160 } 160 }
161 OPENSSL_free(b); 161 free(b);
162 return(ret); 162 return(ret);
163 } 163 }
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index 297c45a9ff..6c38ace8f9 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -194,9 +194,9 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
194 p= *pp; 194 p= *pp;
195 pend = p + len; 195 pend = p + len;
196 196
197 /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it 197 /* We must malloc stuff, even for 0 bytes otherwise it
198 * signifies a missing NULL parameter. */ 198 * signifies a missing NULL parameter. */
199 s=(unsigned char *)OPENSSL_malloc((int)len+1); 199 s=(unsigned char *)malloc((int)len+1);
200 if (s == NULL) 200 if (s == NULL)
201 { 201 {
202 i=ERR_R_MALLOC_FAILURE; 202 i=ERR_R_MALLOC_FAILURE;
@@ -249,7 +249,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
249 memcpy(s,p,(int)len); 249 memcpy(s,p,(int)len);
250 } 250 }
251 251
252 if (ret->data != NULL) OPENSSL_free(ret->data); 252 if (ret->data != NULL) free(ret->data);
253 ret->data=s; 253 ret->data=s;
254 ret->length=(int)len; 254 ret->length=(int)len;
255 if (a != NULL) (*a)=ret; 255 if (a != NULL) (*a)=ret;
@@ -300,9 +300,9 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
300 goto err; 300 goto err;
301 } 301 }
302 302
303 /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it 303 /* We must malloc stuff, even for 0 bytes otherwise it
304 * signifies a missing NULL parameter. */ 304 * signifies a missing NULL parameter. */
305 s=(unsigned char *)OPENSSL_malloc((int)len+1); 305 s=(unsigned char *)malloc((int)len+1);
306 if (s == NULL) 306 if (s == NULL)
307 { 307 {
308 i=ERR_R_MALLOC_FAILURE; 308 i=ERR_R_MALLOC_FAILURE;
@@ -319,7 +319,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
319 p+=len; 319 p+=len;
320 } 320 }
321 321
322 if (ret->data != NULL) OPENSSL_free(ret->data); 322 if (ret->data != NULL) free(ret->data);
323 ret->data=s; 323 ret->data=s;
324 ret->length=(int)len; 324 ret->length=(int)len;
325 if (a != NULL) (*a)=ret; 325 if (a != NULL) (*a)=ret;
@@ -343,8 +343,8 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
343 if (a->length < (int)(sizeof(long)+1)) 343 if (a->length < (int)(sizeof(long)+1))
344 { 344 {
345 if (a->data != NULL) 345 if (a->data != NULL)
346 OPENSSL_free(a->data); 346 free(a->data);
347 if ((a->data=(unsigned char *)OPENSSL_malloc(sizeof(long)+1)) != NULL) 347 if ((a->data=(unsigned char *)malloc(sizeof(long)+1)) != NULL)
348 memset((char *)a->data,0,sizeof(long)+1); 348 memset((char *)a->data,0,sizeof(long)+1);
349 } 349 }
350 if (a->data == NULL) 350 if (a->data == NULL)
@@ -422,7 +422,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
422 len=((j == 0)?0:((j/8)+1)); 422 len=((j == 0)?0:((j/8)+1));
423 if (ret->length < len+4) 423 if (ret->length < len+4)
424 { 424 {
425 unsigned char *new_data=OPENSSL_realloc(ret->data, len+4); 425 unsigned char *new_data=realloc(ret->data, len+4);
426 if (!new_data) 426 if (!new_data)
427 { 427 {
428 ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 428 ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index dc953c8325..f6d8da8b3c 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -185,7 +185,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
185 dest = *out; 185 dest = *out;
186 if(dest->data) { 186 if(dest->data) {
187 dest->length = 0; 187 dest->length = 0;
188 OPENSSL_free(dest->data); 188 free(dest->data);
189 dest->data = NULL; 189 dest->data = NULL;
190 } 190 }
191 dest->type = str_type; 191 dest->type = str_type;
@@ -231,7 +231,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
231 cpyfunc = cpy_utf8; 231 cpyfunc = cpy_utf8;
232 break; 232 break;
233 } 233 }
234 if(!(p = OPENSSL_malloc(outlen + 1))) { 234 if(!(p = malloc(outlen + 1))) {
235 if(free_out) ASN1_STRING_free(dest); 235 if(free_out) ASN1_STRING_free(dest);
236 ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY,ERR_R_MALLOC_FAILURE); 236 ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY,ERR_R_MALLOC_FAILURE);
237 return -1; 237 return -1;
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index 3978c9150d..c30f32442d 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -180,9 +180,9 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
180 if (blsize > tmpsize) 180 if (blsize > tmpsize)
181 { 181 {
182 if (tmp != ftmp) 182 if (tmp != ftmp)
183 OPENSSL_free(tmp); 183 free(tmp);
184 tmpsize = blsize + 32; 184 tmpsize = blsize + 32;
185 tmp = OPENSSL_malloc(tmpsize); 185 tmp = malloc(tmpsize);
186 if (!tmp) 186 if (!tmp)
187 goto err; 187 goto err;
188 } 188 }
@@ -215,13 +215,13 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
215 len+=i; 215 len+=i;
216 } 216 }
217 if (tmp != ftmp) 217 if (tmp != ftmp)
218 OPENSSL_free(tmp); 218 free(tmp);
219 if (bl) 219 if (bl)
220 BN_free(bl); 220 BN_free(bl);
221 return(len); 221 return(len);
222err: 222err:
223 if (tmp != ftmp) 223 if (tmp != ftmp)
224 OPENSSL_free(tmp); 224 free(tmp);
225 if (bl) 225 if (bl)
226 BN_free(bl); 226 BN_free(bl);
227 return(0); 227 return(0);
@@ -242,7 +242,7 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
242 i=i2t_ASN1_OBJECT(buf,sizeof buf,a); 242 i=i2t_ASN1_OBJECT(buf,sizeof buf,a);
243 if (i > (int)(sizeof(buf) - 1)) 243 if (i > (int)(sizeof(buf) - 1))
244 { 244 {
245 p = OPENSSL_malloc(i + 1); 245 p = malloc(i + 1);
246 if (!p) 246 if (!p)
247 return -1; 247 return -1;
248 i2t_ASN1_OBJECT(p,i + 1,a); 248 i2t_ASN1_OBJECT(p,i + 1,a);
@@ -251,7 +251,7 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
251 return BIO_write(bp, "<INVALID>", 9); 251 return BIO_write(bp, "<INVALID>", 9);
252 BIO_write(bp,p,i); 252 BIO_write(bp,p,i);
253 if (p != buf) 253 if (p != buf)
254 OPENSSL_free(p); 254 free(p);
255 return(i); 255 return(i);
256 } 256 }
257 257
@@ -319,8 +319,8 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
319 if ((data == NULL) || (ret->length < len)) 319 if ((data == NULL) || (ret->length < len))
320 { 320 {
321 ret->length=0; 321 ret->length=0;
322 if (data != NULL) OPENSSL_free(data); 322 if (data != NULL) free(data);
323 data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1); 323 data=(unsigned char *)malloc(len ? (int)len : 1);
324 if (data == NULL) 324 if (data == NULL)
325 { i=ERR_R_MALLOC_FAILURE; goto err; } 325 { i=ERR_R_MALLOC_FAILURE; goto err; }
326 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 326 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
@@ -348,7 +348,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
348 { 348 {
349 ASN1_OBJECT *ret; 349 ASN1_OBJECT *ret;
350 350
351 ret=(ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT)); 351 ret=(ASN1_OBJECT *)malloc(sizeof(ASN1_OBJECT));
352 if (ret == NULL) 352 if (ret == NULL)
353 { 353 {
354 ASN1err(ASN1_F_ASN1_OBJECT_NEW,ERR_R_MALLOC_FAILURE); 354 ASN1err(ASN1_F_ASN1_OBJECT_NEW,ERR_R_MALLOC_FAILURE);
@@ -369,19 +369,19 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
369 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) 369 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS)
370 { 370 {
371#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */ 371#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */
372 if (a->sn != NULL) OPENSSL_free((void *)a->sn); 372 if (a->sn != NULL) free((void *)a->sn);
373 if (a->ln != NULL) OPENSSL_free((void *)a->ln); 373 if (a->ln != NULL) free((void *)a->ln);
374#endif 374#endif
375 a->sn=a->ln=NULL; 375 a->sn=a->ln=NULL;
376 } 376 }
377 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) 377 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA)
378 { 378 {
379 if (a->data != NULL) OPENSSL_free((void *)a->data); 379 if (a->data != NULL) free((void *)a->data);
380 a->data=NULL; 380 a->data=NULL;
381 a->length=0; 381 a->length=0;
382 } 382 }
383 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC) 383 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)
384 OPENSSL_free(a); 384 free(a);
385 } 385 }
386 386
387ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, 387ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 01b6292b65..0433b49a64 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -211,7 +211,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
211 211
212 inl=ASN1_item_i2d(asn,&buf_in, it); 212 inl=ASN1_item_i2d(asn,&buf_in, it);
213 outll=outl=EVP_PKEY_size(pkey); 213 outll=outl=EVP_PKEY_size(pkey);
214 buf_out=OPENSSL_malloc((unsigned int)outl); 214 buf_out=malloc((unsigned int)outl);
215 if ((buf_in == NULL) || (buf_out == NULL)) 215 if ((buf_in == NULL) || (buf_out == NULL))
216 { 216 {
217 outl=0; 217 outl=0;
@@ -226,7 +226,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
226 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_EVP_LIB); 226 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_EVP_LIB);
227 goto err; 227 goto err;
228 } 228 }
229 if (signature->data != NULL) OPENSSL_free(signature->data); 229 if (signature->data != NULL) free(signature->data);
230 signature->data=buf_out; 230 signature->data=buf_out;
231 buf_out=NULL; 231 buf_out=NULL;
232 signature->length=outl; 232 signature->length=outl;
@@ -238,8 +238,8 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
238err: 238err:
239 EVP_MD_CTX_cleanup(ctx); 239 EVP_MD_CTX_cleanup(ctx);
240 if (buf_in != NULL) 240 if (buf_in != NULL)
241 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); OPENSSL_free(buf_in); } 241 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); free(buf_in); }
242 if (buf_out != NULL) 242 if (buf_out != NULL)
243 { OPENSSL_cleanse((char *)buf_out,outll); OPENSSL_free(buf_out); } 243 { OPENSSL_cleanse((char *)buf_out,outll); free(buf_out); }
244 return(outl); 244 return(outl);
245 } 245 }
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index d1a587ccc1..713b3cb028 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -278,12 +278,12 @@ static int do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING
278 t.type = str->type; 278 t.type = str->type;
279 t.value.ptr = (char *)str; 279 t.value.ptr = (char *)str;
280 der_len = i2d_ASN1_TYPE(&t, NULL); 280 der_len = i2d_ASN1_TYPE(&t, NULL);
281 der_buf = OPENSSL_malloc(der_len); 281 der_buf = malloc(der_len);
282 if(!der_buf) return -1; 282 if(!der_buf) return -1;
283 p = der_buf; 283 p = der_buf;
284 i2d_ASN1_TYPE(&t, &p); 284 i2d_ASN1_TYPE(&t, &p);
285 outlen = do_hex_dump(io_ch, arg, der_buf, der_len); 285 outlen = do_hex_dump(io_ch, arg, der_buf, der_len);
286 OPENSSL_free(der_buf); 286 free(der_buf);
287 if(outlen < 0) return -1; 287 if(outlen < 0) return -1;
288 return outlen + 1; 288 return outlen + 1;
289} 289}
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index 2fc48c1551..74bc7b316c 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -222,7 +222,7 @@ int ASN1_STRING_TABLE_add(int nid,
222 return 0; 222 return 0;
223 } 223 }
224 if(!(tmp = ASN1_STRING_TABLE_get(nid))) { 224 if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
225 tmp = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE)); 225 tmp = malloc(sizeof(ASN1_STRING_TABLE));
226 if(!tmp) { 226 if(!tmp) {
227 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, 227 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
228 ERR_R_MALLOC_FAILURE); 228 ERR_R_MALLOC_FAILURE);
@@ -250,7 +250,7 @@ void ASN1_STRING_TABLE_cleanup(void)
250 250
251static void st_free(ASN1_STRING_TABLE *tbl) 251static void st_free(ASN1_STRING_TABLE *tbl)
252{ 252{
253 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl); 253 if(tbl->flags & STABLE_FLAGS_MALLOC) free(tbl);
254} 254}
255 255
256 256
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index f2e7de16af..0e7aca90a7 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -203,14 +203,14 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
203 p=(char *)s->data; 203 p=(char *)s->data;
204 if ((p == NULL) || ((size_t)s->length < len)) 204 if ((p == NULL) || ((size_t)s->length < len))
205 { 205 {
206 p=OPENSSL_malloc(len); 206 p=malloc(len);
207 if (p == NULL) 207 if (p == NULL)
208 { 208 {
209 ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE); 209 ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
210 return(NULL); 210 return(NULL);
211 } 211 }
212 if (s->data != NULL) 212 if (s->data != NULL)
213 OPENSSL_free(s->data); 213 free(s->data);
214 s->data=(unsigned char *)p; 214 s->data=(unsigned char *)p;
215 } 215 }
216 216
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index 5eb47d768c..8eca970be3 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -154,7 +154,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
154 } 154 }
155 155
156 OPENSSL_cleanse(buf_in,(unsigned int)inl); 156 OPENSSL_cleanse(buf_in,(unsigned int)inl);
157 OPENSSL_free(buf_in); 157 free(buf_in);
158 158
159 if (EVP_DigestVerifyFinal(&ctx,signature->data, 159 if (EVP_DigestVerifyFinal(&ctx,signature->data,
160 (size_t)signature->length) <= 0) 160 (size_t)signature->length) <= 0)
diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c
index a19e058fca..228392f1e6 100644
--- a/src/lib/libcrypto/asn1/ameth_lib.c
+++ b/src/lib/libcrypto/asn1/ameth_lib.c
@@ -289,7 +289,7 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
289 const char *pem_str, const char *info) 289 const char *pem_str, const char *info)
290 { 290 {
291 EVP_PKEY_ASN1_METHOD *ameth; 291 EVP_PKEY_ASN1_METHOD *ameth;
292 ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD)); 292 ameth = malloc(sizeof(EVP_PKEY_ASN1_METHOD));
293 if (!ameth) 293 if (!ameth)
294 return NULL; 294 return NULL;
295 295
@@ -393,10 +393,10 @@ void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
393 if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) 393 if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC))
394 { 394 {
395 if (ameth->pem_str) 395 if (ameth->pem_str)
396 OPENSSL_free(ameth->pem_str); 396 free(ameth->pem_str);
397 if (ameth->info) 397 if (ameth->info)
398 OPENSSL_free(ameth->info); 398 free(ameth->info);
399 OPENSSL_free(ameth); 399 free(ameth);
400 } 400 }
401 } 401 }
402 402
diff --git a/src/lib/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c
index 81a7a38895..8194beeb30 100644
--- a/src/lib/libcrypto/asn1/asn1_gen.c
+++ b/src/lib/libcrypto/asn1/asn1_gen.c
@@ -226,7 +226,7 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf)
226 226
227 /* Allocate buffer for new encoding */ 227 /* Allocate buffer for new encoding */
228 228
229 new_der = OPENSSL_malloc(len); 229 new_der = malloc(len);
230 if (!new_der) 230 if (!new_der)
231 goto err; 231 goto err;
232 232
@@ -266,9 +266,9 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf)
266 266
267 err: 267 err:
268 if (orig_der) 268 if (orig_der)
269 OPENSSL_free(orig_der); 269 free(orig_der);
270 if (new_der) 270 if (new_der)
271 OPENSSL_free(new_der); 271 free(new_der);
272 272
273 return ret; 273 return ret;
274 274
@@ -499,7 +499,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
499 bad: 499 bad:
500 500
501 if (der) 501 if (der)
502 OPENSSL_free(der); 502 free(der);
503 503
504 if (sk) 504 if (sk)
505 sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); 505 sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 4d1d6af18d..7b06b6fdc8 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -383,9 +383,9 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
383 { 383 {
384 c=str->data; 384 c=str->data;
385 if (c == NULL) 385 if (c == NULL)
386 str->data=OPENSSL_malloc(len+1); 386 str->data=malloc(len+1);
387 else 387 else
388 str->data=OPENSSL_realloc(c,len+1); 388 str->data=realloc(c,len+1);
389 389
390 if (str->data == NULL) 390 if (str->data == NULL)
391 { 391 {
@@ -407,7 +407,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
407void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) 407void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
408 { 408 {
409 if (str->data) 409 if (str->data)
410 OPENSSL_free(str->data); 410 free(str->data);
411 str->data = data; 411 str->data = data;
412 str->length = len; 412 str->length = len;
413 } 413 }
@@ -422,7 +422,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
422 { 422 {
423 ASN1_STRING *ret; 423 ASN1_STRING *ret;
424 424
425 ret=(ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING)); 425 ret=(ASN1_STRING *)malloc(sizeof(ASN1_STRING));
426 if (ret == NULL) 426 if (ret == NULL)
427 { 427 {
428 ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE); 428 ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE);
@@ -439,8 +439,8 @@ void ASN1_STRING_free(ASN1_STRING *a)
439 { 439 {
440 if (a == NULL) return; 440 if (a == NULL) return;
441 if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF)) 441 if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
442 OPENSSL_free(a->data); 442 free(a->data);
443 OPENSSL_free(a); 443 free(a);
444 } 444 }
445 445
446int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) 446int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
diff --git a/src/lib/libcrypto/asn1/asn1_mac.h b/src/lib/libcrypto/asn1/asn1_mac.h
index c60b197552..ecc2c77228 100644
--- a/src/lib/libcrypto/asn1/asn1_mac.h
+++ b/src/lib/libcrypto/asn1/asn1_mac.h
@@ -289,7 +289,7 @@ err:\
289 289
290/* New macros */ 290/* New macros */
291#define M_ASN1_New_Malloc(ret,type) \ 291#define M_ASN1_New_Malloc(ret,type) \
292 if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ 292 if ((ret=(type *)malloc(sizeof(type))) == NULL) \
293 { c.line=__LINE__; goto err2; } 293 { c.line=__LINE__; goto err2; }
294 294
295#define M_ASN1_New(arg,func) \ 295#define M_ASN1_New(arg,func) \
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c
index 54a704a969..d94b3cd6f8 100644
--- a/src/lib/libcrypto/asn1/asn_mime.c
+++ b/src/lib/libcrypto/asn1/asn_mime.c
@@ -220,7 +220,7 @@ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs)
220 if (rv > 0) 220 if (rv > 0)
221 { 221 {
222 BIO_puts(out, micstr); 222 BIO_puts(out, micstr);
223 OPENSSL_free(micstr); 223 free(micstr);
224 continue; 224 continue;
225 } 225 }
226 if (rv != -2) 226 if (rv != -2)
@@ -822,7 +822,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
822 } 822 }
823 } 823 }
824 } else tmpval = NULL; 824 } else tmpval = NULL;
825 mhdr = (MIME_HEADER *) OPENSSL_malloc(sizeof(MIME_HEADER)); 825 mhdr = (MIME_HEADER *) malloc(sizeof(MIME_HEADER));
826 if(!mhdr) return NULL; 826 if(!mhdr) return NULL;
827 mhdr->name = tmpname; 827 mhdr->name = tmpname;
828 mhdr->value = tmpval; 828 mhdr->value = tmpval;
@@ -851,7 +851,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
851 if(!tmpval) return 0; 851 if(!tmpval) return 0;
852 } else tmpval = NULL; 852 } else tmpval = NULL;
853 /* Parameter values are case sensitive so leave as is */ 853 /* Parameter values are case sensitive so leave as is */
854 mparam = (MIME_PARAM *) OPENSSL_malloc(sizeof(MIME_PARAM)); 854 mparam = (MIME_PARAM *) malloc(sizeof(MIME_PARAM));
855 if(!mparam) return 0; 855 if(!mparam) return 0;
856 mparam->param_name = tmpname; 856 mparam->param_name = tmpname;
857 mparam->param_value = tmpval; 857 mparam->param_value = tmpval;
@@ -900,17 +900,17 @@ static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
900 900
901static void mime_hdr_free(MIME_HEADER *hdr) 901static void mime_hdr_free(MIME_HEADER *hdr)
902{ 902{
903 if(hdr->name) OPENSSL_free(hdr->name); 903 if(hdr->name) free(hdr->name);
904 if(hdr->value) OPENSSL_free(hdr->value); 904 if(hdr->value) free(hdr->value);
905 if(hdr->params) sk_MIME_PARAM_pop_free(hdr->params, mime_param_free); 905 if(hdr->params) sk_MIME_PARAM_pop_free(hdr->params, mime_param_free);
906 OPENSSL_free(hdr); 906 free(hdr);
907} 907}
908 908
909static void mime_param_free(MIME_PARAM *param) 909static void mime_param_free(MIME_PARAM *param)
910{ 910{
911 if(param->param_name) OPENSSL_free(param->param_name); 911 if(param->param_name) free(param->param_name);
912 if(param->param_value) OPENSSL_free(param->param_value); 912 if(param->param_value) free(param->param_value);
913 OPENSSL_free(param); 913 free(param);
914} 914}
915 915
916/* Check for a multipart boundary. Returns: 916/* Check for a multipart boundary. Returns:
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c
index 1ea6a59248..fd04d11459 100644
--- a/src/lib/libcrypto/asn1/asn_moid.c
+++ b/src/lib/libcrypto/asn1/asn_moid.c
@@ -145,7 +145,7 @@ static int do_create(char *value, char *name)
145 p--; 145 p--;
146 } 146 }
147 p++; 147 p++;
148 lntmp = OPENSSL_malloc((p - ln) + 1); 148 lntmp = malloc((p - ln) + 1);
149 if (lntmp == NULL) 149 if (lntmp == NULL)
150 return 0; 150 return 0;
151 memcpy(lntmp, ln, p - ln); 151 memcpy(lntmp, ln, p - ln);
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c
index 1886508654..13dc5d4665 100644
--- a/src/lib/libcrypto/asn1/asn_pack.c
+++ b/src/lib/libcrypto/asn1/asn_pack.c
@@ -75,7 +75,7 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
75 } else octmp = *oct; 75 } else octmp = *oct;
76 76
77 if(octmp->data) { 77 if(octmp->data) {
78 OPENSSL_free(octmp->data); 78 free(octmp->data);
79 octmp->data = NULL; 79 octmp->data = NULL;
80 } 80 }
81 81
diff --git a/src/lib/libcrypto/asn1/bio_asn1.c b/src/lib/libcrypto/asn1/bio_asn1.c
index dc7efd551c..fa98dba728 100644
--- a/src/lib/libcrypto/asn1/bio_asn1.c
+++ b/src/lib/libcrypto/asn1/bio_asn1.c
@@ -150,7 +150,7 @@ BIO_METHOD *BIO_f_asn1(void)
150static int asn1_bio_new(BIO *b) 150static int asn1_bio_new(BIO *b)
151 { 151 {
152 BIO_ASN1_BUF_CTX *ctx; 152 BIO_ASN1_BUF_CTX *ctx;
153 ctx = OPENSSL_malloc(sizeof(BIO_ASN1_BUF_CTX)); 153 ctx = malloc(sizeof(BIO_ASN1_BUF_CTX));
154 if (!ctx) 154 if (!ctx)
155 return 0; 155 return 0;
156 if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE)) 156 if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE))
@@ -163,7 +163,7 @@ static int asn1_bio_new(BIO *b)
163 163
164static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size) 164static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size)
165 { 165 {
166 ctx->buf = OPENSSL_malloc(size); 166 ctx->buf = malloc(size);
167 if (!ctx->buf) 167 if (!ctx->buf)
168 return 0; 168 return 0;
169 ctx->bufsize = size; 169 ctx->bufsize = size;
@@ -186,8 +186,8 @@ static int asn1_bio_free(BIO *b)
186 if (ctx == NULL) 186 if (ctx == NULL)
187 return 0; 187 return 0;
188 if (ctx->buf) 188 if (ctx->buf)
189 OPENSSL_free(ctx->buf); 189 free(ctx->buf);
190 OPENSSL_free(ctx); 190 free(ctx);
191 b->init = 0; 191 b->init = 0;
192 b->ptr = NULL; 192 b->ptr = NULL;
193 b->flags = 0; 193 b->flags = 0;
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c
index b91f97a1b1..60f324bdae 100644
--- a/src/lib/libcrypto/asn1/bio_ndef.c
+++ b/src/lib/libcrypto/asn1/bio_ndef.c
@@ -110,7 +110,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
110 ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED); 110 ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED);
111 return NULL; 111 return NULL;
112 } 112 }
113 ndef_aux = OPENSSL_malloc(sizeof(NDEF_SUPPORT)); 113 ndef_aux = malloc(sizeof(NDEF_SUPPORT));
114 asn_bio = BIO_new(BIO_f_asn1()); 114 asn_bio = BIO_new(BIO_f_asn1());
115 115
116 /* ASN1 bio needs to be next to output BIO */ 116 /* ASN1 bio needs to be next to output BIO */
@@ -148,7 +148,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
148 if (asn_bio) 148 if (asn_bio)
149 BIO_free(asn_bio); 149 BIO_free(asn_bio);
150 if (ndef_aux) 150 if (ndef_aux)
151 OPENSSL_free(ndef_aux); 151 free(ndef_aux);
152 return NULL; 152 return NULL;
153 } 153 }
154 154
@@ -164,7 +164,7 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
164 ndef_aux = *(NDEF_SUPPORT **)parg; 164 ndef_aux = *(NDEF_SUPPORT **)parg;
165 165
166 derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); 166 derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it);
167 p = OPENSSL_malloc(derlen); 167 p = malloc(derlen);
168 ndef_aux->derbuf = p; 168 ndef_aux->derbuf = p;
169 *pbuf = p; 169 *pbuf = p;
170 derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); 170 derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
@@ -187,7 +187,7 @@ static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg)
187 ndef_aux = *(NDEF_SUPPORT **)parg; 187 ndef_aux = *(NDEF_SUPPORT **)parg;
188 188
189 if (ndef_aux->derbuf) 189 if (ndef_aux->derbuf)
190 OPENSSL_free(ndef_aux->derbuf); 190 free(ndef_aux->derbuf);
191 191
192 ndef_aux->derbuf = NULL; 192 ndef_aux->derbuf = NULL;
193 *pbuf = NULL; 193 *pbuf = NULL;
@@ -200,7 +200,7 @@ static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg)
200 NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg; 200 NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg;
201 if (!ndef_prefix_free(b, pbuf, plen, parg)) 201 if (!ndef_prefix_free(b, pbuf, plen, parg))
202 return 0; 202 return 0;
203 OPENSSL_free(*pndef_aux); 203 free(*pndef_aux);
204 *pndef_aux = NULL; 204 *pndef_aux = NULL;
205 return 1; 205 return 1;
206 } 206 }
@@ -229,7 +229,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
229 return 0; 229 return 0;
230 230
231 derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); 231 derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it);
232 p = OPENSSL_malloc(derlen); 232 p = malloc(derlen);
233 ndef_aux->derbuf = p; 233 ndef_aux->derbuf = p;
234 *pbuf = p; 234 *pbuf = p;
235 derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); 235 derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c
index 56e3cc8df2..caf34ee97e 100644
--- a/src/lib/libcrypto/asn1/f_enum.c
+++ b/src/lib/libcrypto/asn1/f_enum.c
@@ -153,15 +153,15 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
153 if (num+i > slen) 153 if (num+i > slen)
154 { 154 {
155 if (s == NULL) 155 if (s == NULL)
156 sp=(unsigned char *)OPENSSL_malloc( 156 sp=(unsigned char *)malloc(
157 (unsigned int)num+i*2); 157 (unsigned int)num+i*2);
158 else 158 else
159 sp=(unsigned char *)OPENSSL_realloc(s, 159 sp=(unsigned char *)realloc(s,
160 (unsigned int)num+i*2); 160 (unsigned int)num+i*2);
161 if (sp == NULL) 161 if (sp == NULL)
162 { 162 {
163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
164 if (s != NULL) OPENSSL_free(s); 164 if (s != NULL) free(s);
165 goto err; 165 goto err;
166 } 166 }
167 s=sp; 167 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 8b92fad9df..977e3d01b7 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -157,14 +157,14 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
157 if (num+i > slen) 157 if (num+i > slen)
158 { 158 {
159 if (s == NULL) 159 if (s == NULL)
160 sp=(unsigned char *)OPENSSL_malloc( 160 sp=(unsigned char *)malloc(
161 (unsigned int)num+i*2); 161 (unsigned int)num+i*2);
162 else 162 else
163 sp=OPENSSL_realloc_clean(s,slen,num+i*2); 163 sp=OPENSSL_realloc_clean(s,slen,num+i*2);
164 if (sp == NULL) 164 if (sp == NULL)
165 { 165 {
166 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 166 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
167 if (s != NULL) OPENSSL_free(s); 167 if (s != NULL) free(s);
168 goto err; 168 goto err;
169 } 169 }
170 s=sp; 170 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index f7d36adac7..f4bee15335 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -149,15 +149,15 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
149 if (num+i > slen) 149 if (num+i > slen)
150 { 150 {
151 if (s == NULL) 151 if (s == NULL)
152 sp=(unsigned char *)OPENSSL_malloc( 152 sp=(unsigned char *)malloc(
153 (unsigned int)num+i*2); 153 (unsigned int)num+i*2);
154 else 154 else
155 sp=(unsigned char *)OPENSSL_realloc(s, 155 sp=(unsigned char *)realloc(s,
156 (unsigned int)num+i*2); 156 (unsigned int)num+i*2);
157 if (sp == NULL) 157 if (sp == NULL)
158 { 158 {
159 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 159 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
160 if (s != NULL) OPENSSL_free(s); 160 if (s != NULL) free(s);
161 goto err; 161 goto err;
162 } 162 }
163 s=sp; 163 s=sp;
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index e251739933..97647d17e1 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -169,7 +169,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
169 169
170 170
171 /* Since its RC4 encrypted length is actual length */ 171 /* Since its RC4 encrypted length is actual length */
172 if ((zz=(unsigned char *)OPENSSL_malloc(rsalen)) == NULL) 172 if ((zz=(unsigned char *)malloc(rsalen)) == NULL)
173 { 173 {
174 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE); 174 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE);
175 goto err; 175 goto err;
@@ -179,7 +179,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
179 /* Write out private key encoding */ 179 /* Write out private key encoding */
180 i2d_RSAPrivateKey(a,&zz); 180 i2d_RSAPrivateKey(a,&zz);
181 181
182 if ((zz=OPENSSL_malloc(pkeylen)) == NULL) 182 if ((zz=malloc(pkeylen)) == NULL)
183 { 183 {
184 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE); 184 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE);
185 goto err; 185 goto err;
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 4ea683036b..2d80334e01 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -214,7 +214,7 @@ X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
214 214
215 if (!saltlen) 215 if (!saltlen)
216 saltlen = PKCS5_SALT_LEN; 216 saltlen = PKCS5_SALT_LEN;
217 if (!(osalt->data = OPENSSL_malloc (saltlen))) 217 if (!(osalt->data = malloc (saltlen)))
218 goto merr; 218 goto merr;
219 219
220 osalt->length = saltlen; 220 osalt->length = saltlen;
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index c61169208a..f6550b2b04 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -97,7 +97,7 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
97 X509_signature_print(out, x->sig_alg, NULL); 97 X509_signature_print(out, x->sig_alg, NULL);
98 p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0); 98 p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0);
99 BIO_printf(out,"%8sIssuer: %s\n","",p); 99 BIO_printf(out,"%8sIssuer: %s\n","",p);
100 OPENSSL_free(p); 100 free(p);
101 BIO_printf(out,"%8sLast Update: ",""); 101 BIO_printf(out,"%8sLast Update: ","");
102 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x)); 102 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x));
103 BIO_printf(out,"\n%8sNext Update: ",""); 103 BIO_printf(out,"\n%8sNext Update: ","");
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index bbf00c7a29..8dfda07b92 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -239,7 +239,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
239 } 239 }
240 ret=1; 240 ret=1;
241err: 241err:
242 if (m != NULL) OPENSSL_free(m); 242 if (m != NULL) free(m);
243 return(ret); 243 return(ret);
244 } 244 }
245 245
@@ -256,7 +256,7 @@ int X509_ocspid_print (BIO *bp, X509 *x)
256 if (BIO_printf(bp," Subject OCSP hash: ") <= 0) 256 if (BIO_printf(bp," Subject OCSP hash: ") <= 0)
257 goto err; 257 goto err;
258 derlen = i2d_X509_NAME(x->cert_info->subject, NULL); 258 derlen = i2d_X509_NAME(x->cert_info->subject, NULL);
259 if ((der = dertmp = (unsigned char *)OPENSSL_malloc (derlen)) == NULL) 259 if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL)
260 goto err; 260 goto err;
261 i2d_X509_NAME(x->cert_info->subject, &dertmp); 261 i2d_X509_NAME(x->cert_info->subject, &dertmp);
262 262
@@ -266,7 +266,7 @@ int X509_ocspid_print (BIO *bp, X509 *x)
266 { 266 {
267 if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err; 267 if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err;
268 } 268 }
269 OPENSSL_free (der); 269 free (der);
270 der=NULL; 270 der=NULL;
271 271
272 /* display the hash of the public key as it would appear 272 /* display the hash of the public key as it would appear
@@ -287,7 +287,7 @@ int X509_ocspid_print (BIO *bp, X509 *x)
287 287
288 return (1); 288 return (1);
289err: 289err:
290 if (der != NULL) OPENSSL_free(der); 290 if (der != NULL) free(der);
291 return(0); 291 return(0);
292 } 292 }
293 293
@@ -477,7 +477,7 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
477 b=X509_NAME_oneline(name,NULL,0); 477 b=X509_NAME_oneline(name,NULL,0);
478 if (!*b) 478 if (!*b)
479 { 479 {
480 OPENSSL_free(b); 480 free(b);
481 return 1; 481 return 1;
482 } 482 }
483 s=b+1; /* skip the first slash */ 483 s=b+1; /* skip the first slash */
@@ -513,6 +513,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
513err: 513err:
514 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); 514 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB);
515 } 515 }
516 OPENSSL_free(b); 516 free(b);
517 return(ret); 517 return(ret);
518 } 518 }
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 87d7dfdf5c..c594db9140 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -910,7 +910,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
910 *in = p; 910 *in = p;
911 ret = 1; 911 ret = 1;
912 err: 912 err:
913 if (free_cont && buf.data) OPENSSL_free(buf.data); 913 if (free_cont && buf.data) free(buf.data);
914 return ret; 914 return ret;
915 } 915 }
916 916
@@ -1046,7 +1046,7 @@ int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
1046 if (*free_cont) 1046 if (*free_cont)
1047 { 1047 {
1048 if (stmp->data) 1048 if (stmp->data)
1049 OPENSSL_free(stmp->data); 1049 free(stmp->data);
1050 stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */ 1050 stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
1051 stmp->length = len; 1051 stmp->length = len;
1052 *free_cont = 0; 1052 *free_cont = 0;
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index 936ad1f767..9ab0473d73 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -110,7 +110,7 @@ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
110 len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); 110 len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags);
111 if (len <= 0) 111 if (len <= 0)
112 return len; 112 return len;
113 buf = OPENSSL_malloc(len); 113 buf = malloc(len);
114 if (!buf) 114 if (!buf)
115 return -1; 115 return -1;
116 p = buf; 116 p = buf;
@@ -451,9 +451,9 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
451 do_sort = 0; 451 do_sort = 0;
452 else 452 else
453 { 453 {
454 derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) 454 derlst = malloc(sk_ASN1_VALUE_num(sk)
455 * sizeof(*derlst)); 455 * sizeof(*derlst));
456 tmpdat = OPENSSL_malloc(skcontlen); 456 tmpdat = malloc(skcontlen);
457 if (!derlst || !tmpdat) 457 if (!derlst || !tmpdat)
458 return 0; 458 return 0;
459 } 459 }
@@ -496,8 +496,8 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
496 i++, tder++) 496 i++, tder++)
497 (void)sk_ASN1_VALUE_set(sk, i, tder->field); 497 (void)sk_ASN1_VALUE_set(sk, i, tder->field);
498 } 498 }
499 OPENSSL_free(derlst); 499 free(derlst);
500 OPENSSL_free(tmpdat); 500 free(tmpdat);
501 return 1; 501 return 1;
502 } 502 }
503 503
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index 77d3092d31..b04034ba4c 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -126,7 +126,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
126 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); 126 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
127 if (!combine) 127 if (!combine)
128 { 128 {
129 OPENSSL_free(*pval); 129 free(*pval);
130 *pval = NULL; 130 *pval = NULL;
131 } 131 }
132 break; 132 break;
@@ -173,7 +173,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
173 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); 173 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
174 if (!combine) 174 if (!combine)
175 { 175 {
176 OPENSSL_free(*pval); 176 free(*pval);
177 *pval = NULL; 177 *pval = NULL;
178 } 178 }
179 break; 179 break;
@@ -254,7 +254,7 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
254 254
255 case V_ASN1_ANY: 255 case V_ASN1_ANY:
256 ASN1_primitive_free(pval, NULL); 256 ASN1_primitive_free(pval, NULL);
257 OPENSSL_free(*pval); 257 free(*pval);
258 break; 258 break;
259 259
260 default: 260 default:
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 0d9e78cc7c..aab9ef08c4 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -160,7 +160,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
160 } 160 }
161 if (!combine) 161 if (!combine)
162 { 162 {
163 *pval = OPENSSL_malloc(it->size); 163 *pval = malloc(it->size);
164 if (!*pval) 164 if (!*pval)
165 goto memerr; 165 goto memerr;
166 memset(*pval, 0, it->size); 166 memset(*pval, 0, it->size);
@@ -188,7 +188,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
188 } 188 }
189 if (!combine) 189 if (!combine)
190 { 190 {
191 *pval = OPENSSL_malloc(it->size); 191 *pval = malloc(it->size);
192 if (!*pval) 192 if (!*pval)
193 goto memerr; 193 goto memerr;
194 memset(*pval, 0, it->size); 194 memset(*pval, 0, it->size);
@@ -354,7 +354,7 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
354 return 1; 354 return 1;
355 355
356 case V_ASN1_ANY: 356 case V_ASN1_ANY:
357 typ = OPENSSL_malloc(sizeof(ASN1_TYPE)); 357 typ = malloc(sizeof(ASN1_TYPE));
358 if (!typ) 358 if (!typ)
359 return 0; 359 return 0;
360 typ->value.ptr = NULL; 360 typ->value.ptr = NULL;
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index 542a091a66..ec524edac8 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -85,7 +85,7 @@ ASN1_PCTX default_pctx =
85ASN1_PCTX *ASN1_PCTX_new(void) 85ASN1_PCTX *ASN1_PCTX_new(void)
86 { 86 {
87 ASN1_PCTX *ret; 87 ASN1_PCTX *ret;
88 ret = OPENSSL_malloc(sizeof(ASN1_PCTX)); 88 ret = malloc(sizeof(ASN1_PCTX));
89 if (ret == NULL) 89 if (ret == NULL)
90 { 90 {
91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); 91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
@@ -101,7 +101,7 @@ ASN1_PCTX *ASN1_PCTX_new(void)
101 101
102void ASN1_PCTX_free(ASN1_PCTX *p) 102void ASN1_PCTX_free(ASN1_PCTX *p)
103 { 103 {
104 OPENSSL_free(p); 104 free(p);
105 } 105 }
106 106
107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p) 107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
@@ -480,7 +480,7 @@ static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
480 s = i2s_ASN1_INTEGER(NULL, str); 480 s = i2s_ASN1_INTEGER(NULL, str);
481 if (BIO_puts(out, s) <= 0) 481 if (BIO_puts(out, s) <= 0)
482 ret = 0; 482 ret = 0;
483 OPENSSL_free(s); 483 free(s);
484 return ret; 484 return ret;
485 } 485 }
486 486
diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c
index ca9ec7a32f..dfa63fb2bc 100644
--- a/src/lib/libcrypto/asn1/tasn_utl.c
+++ b/src/lib/libcrypto/asn1/tasn_utl.c
@@ -155,7 +155,7 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
155 if (enc) 155 if (enc)
156 { 156 {
157 if (enc->enc) 157 if (enc->enc)
158 OPENSSL_free(enc->enc); 158 free(enc->enc);
159 enc->enc = NULL; 159 enc->enc = NULL;
160 enc->len = 0; 160 enc->len = 0;
161 enc->modified = 1; 161 enc->modified = 1;
@@ -171,8 +171,8 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
171 return 1; 171 return 1;
172 172
173 if (enc->enc) 173 if (enc->enc)
174 OPENSSL_free(enc->enc); 174 free(enc->enc);
175 enc->enc = OPENSSL_malloc(inlen); 175 enc->enc = malloc(inlen);
176 if (!enc->enc) 176 if (!enc->enc)
177 return 0; 177 return 0;
178 memcpy(enc->enc, in, inlen); 178 memcpy(enc->enc, in, inlen);
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index c51c690ba9..cf7e69aaaf 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -493,7 +493,7 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(
493 int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)) 493 int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk))
494 { 494 {
495 X509_CRL_METHOD *m; 495 X509_CRL_METHOD *m;
496 m = OPENSSL_malloc(sizeof(X509_CRL_METHOD)); 496 m = malloc(sizeof(X509_CRL_METHOD));
497 if (!m) 497 if (!m)
498 return NULL; 498 return NULL;
499 m->crl_init = crl_init; 499 m->crl_init = crl_init;
@@ -508,7 +508,7 @@ void X509_CRL_METHOD_free(X509_CRL_METHOD *m)
508 { 508 {
509 if (!(m->flags & X509_CRL_METHOD_DYNAMIC)) 509 if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
510 return; 510 return;
511 OPENSSL_free(m); 511 free(m);
512 } 512 }
513 513
514void X509_CRL_set_meth_data(X509_CRL *crl, void *dat) 514void X509_CRL_set_meth_data(X509_CRL *crl, void *dat)
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c
index d44f6cdb01..c13fad056f 100644
--- a/src/lib/libcrypto/asn1/x_info.c
+++ b/src/lib/libcrypto/asn1/x_info.c
@@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void)
66 { 66 {
67 X509_INFO *ret=NULL; 67 X509_INFO *ret=NULL;
68 68
69 ret=(X509_INFO *)OPENSSL_malloc(sizeof(X509_INFO)); 69 ret=(X509_INFO *)malloc(sizeof(X509_INFO));
70 if (ret == NULL) 70 if (ret == NULL)
71 { 71 {
72 ASN1err(ASN1_F_X509_INFO_NEW,ERR_R_MALLOC_FAILURE); 72 ASN1err(ASN1_F_X509_INFO_NEW,ERR_R_MALLOC_FAILURE);
@@ -106,8 +106,8 @@ void X509_INFO_free(X509_INFO *x)
106 if (x->x509 != NULL) X509_free(x->x509); 106 if (x->x509 != NULL) X509_free(x->x509);
107 if (x->crl != NULL) X509_CRL_free(x->crl); 107 if (x->crl != NULL) X509_CRL_free(x->crl);
108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); 108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey);
109 if (x->enc_data != NULL) OPENSSL_free(x->enc_data); 109 if (x->enc_data != NULL) free(x->enc_data);
110 OPENSSL_free(x); 110 free(x);
111 } 111 }
112 112
113IMPLEMENT_STACK_OF(X509_INFO) 113IMPLEMENT_STACK_OF(X509_INFO)
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index d7c2318693..e14d329639 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -132,7 +132,7 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)
132static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it) 132static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
133{ 133{
134 X509_NAME *ret = NULL; 134 X509_NAME *ret = NULL;
135 ret = OPENSSL_malloc(sizeof(X509_NAME)); 135 ret = malloc(sizeof(X509_NAME));
136 if(!ret) goto memerr; 136 if(!ret) goto memerr;
137 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL) 137 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL)
138 goto memerr; 138 goto memerr;
@@ -149,7 +149,7 @@ static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
149 { 149 {
150 if (ret->entries) 150 if (ret->entries)
151 sk_X509_NAME_ENTRY_free(ret->entries); 151 sk_X509_NAME_ENTRY_free(ret->entries);
152 OPENSSL_free(ret); 152 free(ret);
153 } 153 }
154 return 0; 154 return 0;
155} 155}
@@ -164,8 +164,8 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
164 BUF_MEM_free(a->bytes); 164 BUF_MEM_free(a->bytes);
165 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free); 165 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free);
166 if (a->canon_enc) 166 if (a->canon_enc)
167 OPENSSL_free(a->canon_enc); 167 free(a->canon_enc);
168 OPENSSL_free(a); 168 free(a);
169 *pval = NULL; 169 *pval = NULL;
170} 170}
171 171
@@ -325,7 +325,7 @@ static int x509_name_canon(X509_NAME *a)
325 325
326 if (a->canon_enc) 326 if (a->canon_enc)
327 { 327 {
328 OPENSSL_free(a->canon_enc); 328 free(a->canon_enc);
329 a->canon_enc = NULL; 329 a->canon_enc = NULL;
330 } 330 }
331 /* Special case: empty X509_NAME => null encoding */ 331 /* Special case: empty X509_NAME => null encoding */
@@ -362,7 +362,7 @@ static int x509_name_canon(X509_NAME *a)
362 362
363 a->canon_enclen = i2d_name_canon(intname, NULL); 363 a->canon_enclen = i2d_name_canon(intname, NULL);
364 364
365 p = OPENSSL_malloc(a->canon_enclen); 365 p = malloc(a->canon_enclen);
366 366
367 if (!p) 367 if (!p)
368 goto err; 368 goto err;
diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c
index 8453618426..3bf2f5e915 100644
--- a/src/lib/libcrypto/asn1/x_pkey.c
+++ b/src/lib/libcrypto/asn1/x_pkey.c
@@ -146,6 +146,6 @@ void X509_PKEY_free(X509_PKEY *x)
146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); 146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor);
147 if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey); 147 if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey);
148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey); 148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey);
149 if ((x->key_data != NULL) && (x->key_free)) OPENSSL_free(x->key_data); 149 if ((x->key_data != NULL) && (x->key_free)) free(x->key_data);
150 OPENSSL_free(x); 150 free(x);
151 } 151 }
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index b649e1fcf9..684f40899f 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -357,7 +357,7 @@ int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
357 if (penc) 357 if (penc)
358 { 358 {
359 if (pub->public_key->data) 359 if (pub->public_key->data)
360 OPENSSL_free(pub->public_key->data); 360 free(pub->public_key->data);
361 pub->public_key->data = penc; 361 pub->public_key->data = penc;
362 pub->public_key->length = penclen; 362 pub->public_key->length = penclen;
363 /* Set number of unused bits to zero */ 363 /* Set number of unused bits to zero */
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c
index de3df9eb51..5734f2b069 100644
--- a/src/lib/libcrypto/asn1/x_x509.c
+++ b/src/lib/libcrypto/asn1/x_x509.c
@@ -105,7 +105,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
105 break; 105 break;
106 106
107 case ASN1_OP_D2I_POST: 107 case ASN1_OP_D2I_POST:
108 if (ret->name != NULL) OPENSSL_free(ret->name); 108 if (ret->name != NULL) free(ret->name);
109 ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0); 109 ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0);
110 break; 110 break;
111 111
@@ -123,7 +123,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
123 ASIdentifiers_free(ret->rfc3779_asid); 123 ASIdentifiers_free(ret->rfc3779_asid);
124#endif 124#endif
125 125
126 if (ret->name != NULL) OPENSSL_free(ret->name); 126 if (ret->name != NULL) free(ret->name);
127 break; 127 break;
128 128
129 } 129 }