summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/conf
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/conf
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/conf')
-rw-r--r--src/lib/libcrypto/conf/conf_api.c24
-rw-r--r--src/lib/libcrypto/conf/conf_def.c32
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c26
3 files changed, 41 insertions, 41 deletions
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c
index f5fcbb9f6b..dc6eb579bf 100644
--- a/src/lib/libcrypto/conf/conf_api.c
+++ b/src/lib/libcrypto/conf/conf_api.c
@@ -119,9 +119,9 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
119 if (v != NULL) 119 if (v != NULL)
120 { 120 {
121 (void)sk_CONF_VALUE_delete_ptr(ts,v); 121 (void)sk_CONF_VALUE_delete_ptr(ts,v);
122 OPENSSL_free(v->name); 122 free(v->name);
123 OPENSSL_free(v->value); 123 free(v->value);
124 OPENSSL_free(v); 124 free(v);
125 } 125 }
126 return 1; 126 return 1;
127 } 127 }
@@ -226,7 +226,7 @@ void _CONF_free_data(CONF *conf)
226 if (conf == NULL || conf->data == NULL) return; 226 if (conf == NULL || conf->data == NULL) return;
227 227
228 lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make 228 lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make
229 * sure the 'OPENSSL_free()' works as 229 * sure the 'free()' works as
230 * expected */ 230 * expected */
231 lh_CONF_VALUE_doall_arg(conf->data, 231 lh_CONF_VALUE_doall_arg(conf->data,
232 LHASH_DOALL_ARG_FN(value_free_hash), 232 LHASH_DOALL_ARG_FN(value_free_hash),
@@ -257,13 +257,13 @@ static void value_free_stack_doall(CONF_VALUE *a)
257 for (i=sk_CONF_VALUE_num(sk)-1; i>=0; i--) 257 for (i=sk_CONF_VALUE_num(sk)-1; i>=0; i--)
258 { 258 {
259 vv=sk_CONF_VALUE_value(sk,i); 259 vv=sk_CONF_VALUE_value(sk,i);
260 OPENSSL_free(vv->value); 260 free(vv->value);
261 OPENSSL_free(vv->name); 261 free(vv->name);
262 OPENSSL_free(vv); 262 free(vv);
263 } 263 }
264 if (sk != NULL) sk_CONF_VALUE_free(sk); 264 if (sk != NULL) sk_CONF_VALUE_free(sk);
265 OPENSSL_free(a->section); 265 free(a->section);
266 OPENSSL_free(a); 266 free(a);
267 } 267 }
268 268
269/* Up until OpenSSL 0.9.5a, this was new_section */ 269/* Up until OpenSSL 0.9.5a, this was new_section */
@@ -275,10 +275,10 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
275 275
276 if ((sk=sk_CONF_VALUE_new_null()) == NULL) 276 if ((sk=sk_CONF_VALUE_new_null()) == NULL)
277 goto err; 277 goto err;
278 if ((v=OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL) 278 if ((v=malloc(sizeof(CONF_VALUE))) == NULL)
279 goto err; 279 goto err;
280 i=strlen(section)+1; 280 i=strlen(section)+1;
281 if ((v->section=OPENSSL_malloc(i)) == NULL) 281 if ((v->section=malloc(i)) == NULL)
282 goto err; 282 goto err;
283 283
284 memcpy(v->section,section,i); 284 memcpy(v->section,section,i);
@@ -292,7 +292,7 @@ err:
292 if (!ok) 292 if (!ok)
293 { 293 {
294 if (sk != NULL) sk_CONF_VALUE_free(sk); 294 if (sk != NULL) sk_CONF_VALUE_free(sk);
295 if (v != NULL) OPENSSL_free(v); 295 if (v != NULL) free(v);
296 v=NULL; 296 v=NULL;
297 } 297 }
298 return(v); 298 return(v);
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index 15e5613e36..32d47458a0 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -129,11 +129,11 @@ static CONF *def_create(CONF_METHOD *meth)
129 { 129 {
130 CONF *ret; 130 CONF *ret;
131 131
132 ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); 132 ret = malloc(sizeof(CONF) + sizeof(unsigned short *));
133 if (ret) 133 if (ret)
134 if (meth->init(ret) == 0) 134 if (meth->init(ret) == 0)
135 { 135 {
136 OPENSSL_free(ret); 136 free(ret);
137 ret = NULL; 137 ret = NULL;
138 } 138 }
139 return ret; 139 return ret;
@@ -167,7 +167,7 @@ static int def_destroy(CONF *conf)
167 { 167 {
168 if (def_destroy_data(conf)) 168 if (def_destroy_data(conf))
169 { 169 {
170 OPENSSL_free(conf); 170 free(conf);
171 return 1; 171 return 1;
172 } 172 }
173 return 0; 173 return 0;
@@ -228,7 +228,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
228 goto err; 228 goto err;
229 } 229 }
230 230
231 section=(char *)OPENSSL_malloc(10); 231 section=(char *)malloc(10);
232 if (section == NULL) 232 if (section == NULL)
233 { 233 {
234 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_MALLOC_FAILURE); 234 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
@@ -373,14 +373,14 @@ again:
373 p++; 373 p++;
374 *p='\0'; 374 *p='\0';
375 375
376 if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) 376 if (!(v=(CONF_VALUE *)malloc(sizeof(CONF_VALUE))))
377 { 377 {
378 CONFerr(CONF_F_DEF_LOAD_BIO, 378 CONFerr(CONF_F_DEF_LOAD_BIO,
379 ERR_R_MALLOC_FAILURE); 379 ERR_R_MALLOC_FAILURE);
380 goto err; 380 goto err;
381 } 381 }
382 if (psection == NULL) psection=section; 382 if (psection == NULL) psection=section;
383 v->name=(char *)OPENSSL_malloc(strlen(pname)+1); 383 v->name=(char *)malloc(strlen(pname)+1);
384 v->value=NULL; 384 v->value=NULL;
385 if (v->name == NULL) 385 if (v->name == NULL)
386 { 386 {
@@ -424,20 +424,20 @@ again:
424 if (vv != NULL) 424 if (vv != NULL)
425 { 425 {
426 sk_CONF_VALUE_delete_ptr(ts,vv); 426 sk_CONF_VALUE_delete_ptr(ts,vv);
427 OPENSSL_free(vv->name); 427 free(vv->name);
428 OPENSSL_free(vv->value); 428 free(vv->value);
429 OPENSSL_free(vv); 429 free(vv);
430 } 430 }
431#endif 431#endif
432 v=NULL; 432 v=NULL;
433 } 433 }
434 } 434 }
435 if (buff != NULL) BUF_MEM_free(buff); 435 if (buff != NULL) BUF_MEM_free(buff);
436 if (section != NULL) OPENSSL_free(section); 436 if (section != NULL) free(section);
437 return(1); 437 return(1);
438err: 438err:
439 if (buff != NULL) BUF_MEM_free(buff); 439 if (buff != NULL) BUF_MEM_free(buff);
440 if (section != NULL) OPENSSL_free(section); 440 if (section != NULL) free(section);
441 if (line != NULL) *line=eline; 441 if (line != NULL) *line=eline;
442 (void) snprintf(btmp,sizeof btmp,"%ld",eline); 442 (void) snprintf(btmp,sizeof btmp,"%ld",eline);
443 ERR_add_error_data(2,"line ",btmp); 443 ERR_add_error_data(2,"line ",btmp);
@@ -448,9 +448,9 @@ err:
448 } 448 }
449 if (v != NULL) 449 if (v != NULL)
450 { 450 {
451 if (v->name != NULL) OPENSSL_free(v->name); 451 if (v->name != NULL) free(v->name);
452 if (v->value != NULL) OPENSSL_free(v->value); 452 if (v->value != NULL) free(v->value);
453 if (v != NULL) OPENSSL_free(v); 453 if (v != NULL) free(v);
454 } 454 }
455 return(0); 455 return(0);
456 } 456 }
@@ -637,9 +637,9 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
637 buf->data[to++]= *(from++); 637 buf->data[to++]= *(from++);
638 } 638 }
639 buf->data[to]='\0'; 639 buf->data[to]='\0';
640 if (*pto != NULL) OPENSSL_free(*pto); 640 if (*pto != NULL) free(*pto);
641 *pto=buf->data; 641 *pto=buf->data;
642 OPENSSL_free(buf); 642 free(buf);
643 return(1); 643 return(1);
644err: 644err:
645 if (buf != NULL) BUF_MEM_free(buf); 645 if (buf != NULL) BUF_MEM_free(buf);
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index 994294f655..652ad6469a 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -197,7 +197,7 @@ int CONF_modules_load_file(const char *filename, const char *appname,
197 197
198 err: 198 err:
199 if (filename == NULL) 199 if (filename == NULL)
200 OPENSSL_free(file); 200 free(file);
201 NCONF_free(conf); 201 NCONF_free(conf);
202 202
203 return ret; 203 return ret;
@@ -296,7 +296,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
296 supported_modules = sk_CONF_MODULE_new_null(); 296 supported_modules = sk_CONF_MODULE_new_null();
297 if (supported_modules == NULL) 297 if (supported_modules == NULL)
298 return NULL; 298 return NULL;
299 tmod = OPENSSL_malloc(sizeof(CONF_MODULE)); 299 tmod = malloc(sizeof(CONF_MODULE));
300 if (tmod == NULL) 300 if (tmod == NULL)
301 return NULL; 301 return NULL;
302 302
@@ -308,7 +308,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
308 308
309 if (!sk_CONF_MODULE_push(supported_modules, tmod)) 309 if (!sk_CONF_MODULE_push(supported_modules, tmod))
310 { 310 {
311 OPENSSL_free(tmod); 311 free(tmod);
312 return NULL; 312 return NULL;
313 } 313 }
314 314
@@ -352,7 +352,7 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
352 CONF_IMODULE *imod = NULL; 352 CONF_IMODULE *imod = NULL;
353 353
354 /* Otherwise add initialized module to list */ 354 /* Otherwise add initialized module to list */
355 imod = OPENSSL_malloc(sizeof(CONF_IMODULE)); 355 imod = malloc(sizeof(CONF_IMODULE));
356 if (!imod) 356 if (!imod)
357 goto err; 357 goto err;
358 358
@@ -404,10 +404,10 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
404 if (imod) 404 if (imod)
405 { 405 {
406 if (imod->name) 406 if (imod->name)
407 OPENSSL_free(imod->name); 407 free(imod->name);
408 if (imod->value) 408 if (imod->value)
409 OPENSSL_free(imod->value); 409 free(imod->value);
410 OPENSSL_free(imod); 410 free(imod);
411 } 411 }
412 412
413 return -1; 413 return -1;
@@ -447,8 +447,8 @@ static void module_free(CONF_MODULE *md)
447 { 447 {
448 if (md->dso) 448 if (md->dso)
449 DSO_free(md->dso); 449 DSO_free(md->dso);
450 OPENSSL_free(md->name); 450 free(md->name);
451 OPENSSL_free(md); 451 free(md);
452 } 452 }
453 453
454/* finish and free up all modules instances */ 454/* finish and free up all modules instances */
@@ -472,9 +472,9 @@ static void module_finish(CONF_IMODULE *imod)
472 if (imod->pmod->finish) 472 if (imod->pmod->finish)
473 imod->pmod->finish(imod); 473 imod->pmod->finish(imod);
474 imod->pmod->links--; 474 imod->pmod->links--;
475 OPENSSL_free(imod->name); 475 free(imod->name);
476 OPENSSL_free(imod->value); 476 free(imod->value);
477 OPENSSL_free(imod); 477 free(imod);
478 } 478 }
479 479
480/* Add a static module to OpenSSL */ 480/* Add a static module to OpenSSL */
@@ -558,7 +558,7 @@ char *CONF_get1_default_config_file(void)
558#endif 558#endif
559 len += strlen(OPENSSL_CONF); 559 len += strlen(OPENSSL_CONF);
560 560
561 file = OPENSSL_malloc(len + 1); 561 file = malloc(len + 1);
562 562
563 if (!file) 563 if (!file)
564 return NULL; 564 return NULL;