diff options
author | beck <> | 2014-04-17 13:37:50 +0000 |
---|---|---|
committer | beck <> | 2014-04-17 13:37:50 +0000 |
commit | bddb7c686e3d1aeb156722adc64b6c35ae720f87 (patch) | |
tree | 7595a93a27385c367802aa17ecf20f96551cf14d /src/lib/libcrypto/engine | |
parent | ecec66222d758996a4ff2671ca5026d9ede5ef76 (diff) | |
download | openbsd-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/engine')
-rw-r--r-- | src/lib/libcrypto/engine/eng_dyn.c | 22 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_lib.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_rsax.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_table.c | 6 |
4 files changed, 20 insertions, 20 deletions
diff --git a/src/lib/libcrypto/engine/eng_dyn.c b/src/lib/libcrypto/engine/eng_dyn.c index 807da7a5eb..7878bd802e 100644 --- a/src/lib/libcrypto/engine/eng_dyn.c +++ b/src/lib/libcrypto/engine/eng_dyn.c | |||
@@ -153,7 +153,7 @@ struct st_dynamic_data_ctx | |||
153 | * structure. */ | 153 | * structure. */ |
154 | static int dynamic_ex_data_idx = -1; | 154 | static int dynamic_ex_data_idx = -1; |
155 | 155 | ||
156 | static void int_free_str(char *s) { OPENSSL_free(s); } | 156 | static void int_free_str(char *s) { free(s); } |
157 | /* Because our ex_data element may or may not get allocated depending on whether | 157 | /* Because our ex_data element may or may not get allocated depending on whether |
158 | * a "first-use" occurs before the ENGINE is freed, we have a memory leak | 158 | * a "first-use" occurs before the ENGINE is freed, we have a memory leak |
159 | * problem to solve. We can't declare a "new" handler for the ex_data as we | 159 | * problem to solve. We can't declare a "new" handler for the ex_data as we |
@@ -170,12 +170,12 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr, | |||
170 | if(ctx->dynamic_dso) | 170 | if(ctx->dynamic_dso) |
171 | DSO_free(ctx->dynamic_dso); | 171 | DSO_free(ctx->dynamic_dso); |
172 | if(ctx->DYNAMIC_LIBNAME) | 172 | if(ctx->DYNAMIC_LIBNAME) |
173 | OPENSSL_free((void*)ctx->DYNAMIC_LIBNAME); | 173 | free((void*)ctx->DYNAMIC_LIBNAME); |
174 | if(ctx->engine_id) | 174 | if(ctx->engine_id) |
175 | OPENSSL_free((void*)ctx->engine_id); | 175 | free((void*)ctx->engine_id); |
176 | if(ctx->dirs) | 176 | if(ctx->dirs) |
177 | sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); | 177 | sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); |
178 | OPENSSL_free(ctx); | 178 | free(ctx); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
@@ -186,7 +186,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr, | |||
186 | static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) | 186 | static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) |
187 | { | 187 | { |
188 | dynamic_data_ctx *c; | 188 | dynamic_data_ctx *c; |
189 | c = OPENSSL_malloc(sizeof(dynamic_data_ctx)); | 189 | c = malloc(sizeof(dynamic_data_ctx)); |
190 | if(!c) | 190 | if(!c) |
191 | { | 191 | { |
192 | ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE); | 192 | ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE); |
@@ -207,7 +207,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) | |||
207 | if(!c->dirs) | 207 | if(!c->dirs) |
208 | { | 208 | { |
209 | ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE); | 209 | ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE); |
210 | OPENSSL_free(c); | 210 | free(c); |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 213 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
@@ -223,7 +223,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) | |||
223 | /* If we lost the race to set the context, c is non-NULL and *ctx is the | 223 | /* If we lost the race to set the context, c is non-NULL and *ctx is the |
224 | * context of the thread that won. */ | 224 | * context of the thread that won. */ |
225 | if(c) | 225 | if(c) |
226 | OPENSSL_free(c); | 226 | free(c); |
227 | return 1; | 227 | return 1; |
228 | } | 228 | } |
229 | 229 | ||
@@ -337,7 +337,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) | |||
337 | if(p && (strlen((const char *)p) < 1)) | 337 | if(p && (strlen((const char *)p) < 1)) |
338 | p = NULL; | 338 | p = NULL; |
339 | if(ctx->DYNAMIC_LIBNAME) | 339 | if(ctx->DYNAMIC_LIBNAME) |
340 | OPENSSL_free((void*)ctx->DYNAMIC_LIBNAME); | 340 | free((void*)ctx->DYNAMIC_LIBNAME); |
341 | if(p) | 341 | if(p) |
342 | ctx->DYNAMIC_LIBNAME = BUF_strdup(p); | 342 | ctx->DYNAMIC_LIBNAME = BUF_strdup(p); |
343 | else | 343 | else |
@@ -351,7 +351,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) | |||
351 | if(p && (strlen((const char *)p) < 1)) | 351 | if(p && (strlen((const char *)p) < 1)) |
352 | p = NULL; | 352 | p = NULL; |
353 | if(ctx->engine_id) | 353 | if(ctx->engine_id) |
354 | OPENSSL_free((void*)ctx->engine_id); | 354 | free((void*)ctx->engine_id); |
355 | if(p) | 355 | if(p) |
356 | ctx->engine_id = BUF_strdup(p); | 356 | ctx->engine_id = BUF_strdup(p); |
357 | else | 357 | else |
@@ -422,10 +422,10 @@ static int int_load(dynamic_data_ctx *ctx) | |||
422 | if(DSO_load(ctx->dynamic_dso, merge, NULL, 0)) | 422 | if(DSO_load(ctx->dynamic_dso, merge, NULL, 0)) |
423 | { | 423 | { |
424 | /* Found what we're looking for */ | 424 | /* Found what we're looking for */ |
425 | OPENSSL_free(merge); | 425 | free(merge); |
426 | return 1; | 426 | return 1; |
427 | } | 427 | } |
428 | OPENSSL_free(merge); | 428 | free(merge); |
429 | } | 429 | } |
430 | return 0; | 430 | return 0; |
431 | } | 431 | } |
diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c index 18a6664645..126bc02296 100644 --- a/src/lib/libcrypto/engine/eng_lib.c +++ b/src/lib/libcrypto/engine/eng_lib.c | |||
@@ -65,7 +65,7 @@ ENGINE *ENGINE_new(void) | |||
65 | { | 65 | { |
66 | ENGINE *ret; | 66 | ENGINE *ret; |
67 | 67 | ||
68 | ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE)); | 68 | ret = (ENGINE *)malloc(sizeof(ENGINE)); |
69 | if(ret == NULL) | 69 | if(ret == NULL) |
70 | { | 70 | { |
71 | ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE); | 71 | ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE); |
@@ -133,7 +133,7 @@ int engine_free_util(ENGINE *e, int locked) | |||
133 | if(e->destroy) | 133 | if(e->destroy) |
134 | e->destroy(e); | 134 | e->destroy(e); |
135 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data); | 135 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data); |
136 | OPENSSL_free(e); | 136 | free(e); |
137 | return 1; | 137 | return 1; |
138 | } | 138 | } |
139 | 139 | ||
@@ -158,7 +158,7 @@ static int int_cleanup_check(int create) | |||
158 | } | 158 | } |
159 | static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) | 159 | static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) |
160 | { | 160 | { |
161 | ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof( | 161 | ENGINE_CLEANUP_ITEM *item = malloc(sizeof( |
162 | ENGINE_CLEANUP_ITEM)); | 162 | ENGINE_CLEANUP_ITEM)); |
163 | if(!item) return NULL; | 163 | if(!item) return NULL; |
164 | item->cb = cb; | 164 | item->cb = cb; |
@@ -184,7 +184,7 @@ void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb) | |||
184 | static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item) | 184 | static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item) |
185 | { | 185 | { |
186 | (*(item->cb))(); | 186 | (*(item->cb))(); |
187 | OPENSSL_free(item); | 187 | free(item); |
188 | } | 188 | } |
189 | void ENGINE_cleanup(void) | 189 | void ENGINE_cleanup(void) |
190 | { | 190 | { |
diff --git a/src/lib/libcrypto/engine/eng_rsax.c b/src/lib/libcrypto/engine/eng_rsax.c index 96e63477ee..fa9159499d 100644 --- a/src/lib/libcrypto/engine/eng_rsax.c +++ b/src/lib/libcrypto/engine/eng_rsax.c | |||
@@ -282,7 +282,7 @@ static E_RSAX_MOD_CTX *e_rsax_get_ctx(RSA *rsa, int idx, BIGNUM* m) | |||
282 | 282 | ||
283 | hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); | 283 | hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); |
284 | if (!hptr) { | 284 | if (!hptr) { |
285 | hptr = OPENSSL_malloc(3*sizeof(E_RSAX_MOD_CTX)); | 285 | hptr = malloc(3*sizeof(E_RSAX_MOD_CTX)); |
286 | if (!hptr) return NULL; | 286 | if (!hptr) return NULL; |
287 | hptr[2].type = hptr[1].type= hptr[0].type = 0; | 287 | hptr[2].type = hptr[1].type= hptr[0].type = 0; |
288 | RSA_set_ex_data(rsa, rsax_ex_data_idx, hptr); | 288 | RSA_set_ex_data(rsa, rsax_ex_data_idx, hptr); |
@@ -307,7 +307,7 @@ static int e_rsax_rsa_finish(RSA *rsa) | |||
307 | E_RSAX_MOD_CTX *hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); | 307 | E_RSAX_MOD_CTX *hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); |
308 | if(hptr) | 308 | if(hptr) |
309 | { | 309 | { |
310 | OPENSSL_free(hptr); | 310 | free(hptr); |
311 | RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL); | 311 | RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL); |
312 | } | 312 | } |
313 | if (rsa->_method_mod_n) | 313 | if (rsa->_method_mod_n) |
diff --git a/src/lib/libcrypto/engine/eng_table.c b/src/lib/libcrypto/engine/eng_table.c index 4fde948185..b7e77f7625 100644 --- a/src/lib/libcrypto/engine/eng_table.c +++ b/src/lib/libcrypto/engine/eng_table.c | |||
@@ -146,14 +146,14 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, | |||
146 | fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); | 146 | fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); |
147 | if(!fnd) | 147 | if(!fnd) |
148 | { | 148 | { |
149 | fnd = OPENSSL_malloc(sizeof(ENGINE_PILE)); | 149 | fnd = malloc(sizeof(ENGINE_PILE)); |
150 | if(!fnd) goto end; | 150 | if(!fnd) goto end; |
151 | fnd->uptodate = 1; | 151 | fnd->uptodate = 1; |
152 | fnd->nid = *nids; | 152 | fnd->nid = *nids; |
153 | fnd->sk = sk_ENGINE_new_null(); | 153 | fnd->sk = sk_ENGINE_new_null(); |
154 | if(!fnd->sk) | 154 | if(!fnd->sk) |
155 | { | 155 | { |
156 | OPENSSL_free(fnd); | 156 | free(fnd); |
157 | goto end; | 157 | goto end; |
158 | } | 158 | } |
159 | fnd->funct = NULL; | 159 | fnd->funct = NULL; |
@@ -218,7 +218,7 @@ static void int_cleanup_cb_doall(ENGINE_PILE *p) | |||
218 | sk_ENGINE_free(p->sk); | 218 | sk_ENGINE_free(p->sk); |
219 | if(p->funct) | 219 | if(p->funct) |
220 | engine_unlocked_finish(p->funct, 0); | 220 | engine_unlocked_finish(p->funct, 0); |
221 | OPENSSL_free(p); | 221 | free(p); |
222 | } | 222 | } |
223 | static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE) | 223 | static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE) |
224 | 224 | ||