summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/mem.c53
-rw-r--r--src/lib/libssl/src/crypto/mem.c53
2 files changed, 36 insertions, 70 deletions
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 86e5ff1c8e..548c248785 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -180,7 +180,8 @@ CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
180 return 1; 180 return 1;
181} 181}
182 182
183int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), 183int
184CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
184 void (*f)(void *)) 185 void (*f)(void *))
185{ 186{
186 if (!allow_customize) 187 if (!allow_customize)
@@ -222,7 +223,8 @@ CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
222 *f = free_func; 223 *f = free_func;
223} 224}
224 225
225void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), 226void
227CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
226 void *(**r)(void *, size_t, const char *, int), void (**f)(void *)) 228 void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
227{ 229{
228 if (m != NULL) 230 if (m != NULL)
@@ -244,7 +246,8 @@ CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
244 *f = free_locked_func; 246 *f = free_locked_func;
245} 247}
246 248
247void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), 249void
250CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
248 void (**f)(void *)) 251 void (**f)(void *))
249{ 252{
250 if (m != NULL) 253 if (m != NULL)
@@ -272,8 +275,8 @@ CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
272} 275}
273 276
274 277
275void 278void *
276*CRYPTO_malloc_locked(int num, const char *file, int line) 279CRYPTO_malloc_locked(int num, const char *file, int line)
277{ 280{
278 void *ret = NULL; 281 void *ret = NULL;
279 282
@@ -292,16 +295,6 @@ void
292 if (malloc_debug_func != NULL) 295 if (malloc_debug_func != NULL)
293 malloc_debug_func(ret, num, file, line, 1); 296 malloc_debug_func(ret, num, file, line, 1);
294 297
295#ifndef OPENSSL_CPUID_OBJ
296 /* Create a dependency on the value of 'cleanse_ctr' so our memory
297 * sanitisation function can't be optimised out. NB: We only do
298 * this for >2Kb so the overhead doesn't bother us. */
299 if (ret && (num > 2048)) {
300 extern unsigned char cleanse_ctr;
301 ((unsigned char *)ret)[0] = cleanse_ctr;
302 }
303#endif
304
305 return ret; 298 return ret;
306} 299}
307 300
@@ -318,8 +311,8 @@ CRYPTO_free_locked(void *str)
318 free_debug_func(NULL, 1); 311 free_debug_func(NULL, 1);
319} 312}
320 313
321void 314void *
322*CRYPTO_malloc(int num, const char *file, int line) 315CRYPTO_malloc(int num, const char *file, int line)
323{ 316{
324 void *ret = NULL; 317 void *ret = NULL;
325 318
@@ -338,21 +331,11 @@ void
338 if (malloc_debug_func != NULL) 331 if (malloc_debug_func != NULL)
339 malloc_debug_func(ret, num, file, line, 1); 332 malloc_debug_func(ret, num, file, line, 1);
340 333
341#ifndef OPENSSL_CPUID_OBJ
342 /* Create a dependency on the value of 'cleanse_ctr' so our memory
343 * sanitisation function can't be optimised out. NB: We only do
344 * this for >2Kb so the overhead doesn't bother us. */
345 if (ret && (num > 2048)) {
346 extern unsigned char cleanse_ctr;
347 ((unsigned char *)ret)[0] = cleanse_ctr;
348 }
349#endif
350
351 return ret; 334 return ret;
352} 335}
353 336
354char 337char *
355*CRYPTO_strdup(const char *str, const char *file, int line) 338CRYPTO_strdup(const char *str, const char *file, int line)
356{ 339{
357 size_t len = strlen(str) + 1; 340 size_t len = strlen(str) + 1;
358 char *ret = CRYPTO_malloc(len, file, line); 341 char *ret = CRYPTO_malloc(len, file, line);
@@ -361,8 +344,8 @@ char
361 return ret; 344 return ret;
362} 345}
363 346
364void 347void *
365*CRYPTO_realloc(void *str, int num, const char *file, int line) 348CRYPTO_realloc(void *str, int num, const char *file, int line)
366{ 349{
367 void *ret = NULL; 350 void *ret = NULL;
368 351
@@ -384,8 +367,8 @@ void
384 return ret; 367 return ret;
385} 368}
386 369
387void 370void *
388*CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, 371CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
389int line) 372int line)
390{ 373{
391 void *ret = NULL; 374 void *ret = NULL;
@@ -433,8 +416,8 @@ CRYPTO_free(void *str)
433 free_debug_func(NULL, 1); 416 free_debug_func(NULL, 1);
434} 417}
435 418
436void 419void *
437*CRYPTO_remalloc(void *a, int num, const char *file, int line) 420CRYPTO_remalloc(void *a, int num, const char *file, int line)
438{ 421{
439 if (a != NULL) 422 if (a != NULL)
440 OPENSSL_free(a); 423 OPENSSL_free(a);
diff --git a/src/lib/libssl/src/crypto/mem.c b/src/lib/libssl/src/crypto/mem.c
index 86e5ff1c8e..548c248785 100644
--- a/src/lib/libssl/src/crypto/mem.c
+++ b/src/lib/libssl/src/crypto/mem.c
@@ -180,7 +180,8 @@ CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
180 return 1; 180 return 1;
181} 181}
182 182
183int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), 183int
184CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
184 void (*f)(void *)) 185 void (*f)(void *))
185{ 186{
186 if (!allow_customize) 187 if (!allow_customize)
@@ -222,7 +223,8 @@ CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
222 *f = free_func; 223 *f = free_func;
223} 224}
224 225
225void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), 226void
227CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
226 void *(**r)(void *, size_t, const char *, int), void (**f)(void *)) 228 void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
227{ 229{
228 if (m != NULL) 230 if (m != NULL)
@@ -244,7 +246,8 @@ CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
244 *f = free_locked_func; 246 *f = free_locked_func;
245} 247}
246 248
247void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), 249void
250CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
248 void (**f)(void *)) 251 void (**f)(void *))
249{ 252{
250 if (m != NULL) 253 if (m != NULL)
@@ -272,8 +275,8 @@ CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
272} 275}
273 276
274 277
275void 278void *
276*CRYPTO_malloc_locked(int num, const char *file, int line) 279CRYPTO_malloc_locked(int num, const char *file, int line)
277{ 280{
278 void *ret = NULL; 281 void *ret = NULL;
279 282
@@ -292,16 +295,6 @@ void
292 if (malloc_debug_func != NULL) 295 if (malloc_debug_func != NULL)
293 malloc_debug_func(ret, num, file, line, 1); 296 malloc_debug_func(ret, num, file, line, 1);
294 297
295#ifndef OPENSSL_CPUID_OBJ
296 /* Create a dependency on the value of 'cleanse_ctr' so our memory
297 * sanitisation function can't be optimised out. NB: We only do
298 * this for >2Kb so the overhead doesn't bother us. */
299 if (ret && (num > 2048)) {
300 extern unsigned char cleanse_ctr;
301 ((unsigned char *)ret)[0] = cleanse_ctr;
302 }
303#endif
304
305 return ret; 298 return ret;
306} 299}
307 300
@@ -318,8 +311,8 @@ CRYPTO_free_locked(void *str)
318 free_debug_func(NULL, 1); 311 free_debug_func(NULL, 1);
319} 312}
320 313
321void 314void *
322*CRYPTO_malloc(int num, const char *file, int line) 315CRYPTO_malloc(int num, const char *file, int line)
323{ 316{
324 void *ret = NULL; 317 void *ret = NULL;
325 318
@@ -338,21 +331,11 @@ void
338 if (malloc_debug_func != NULL) 331 if (malloc_debug_func != NULL)
339 malloc_debug_func(ret, num, file, line, 1); 332 malloc_debug_func(ret, num, file, line, 1);
340 333
341#ifndef OPENSSL_CPUID_OBJ
342 /* Create a dependency on the value of 'cleanse_ctr' so our memory
343 * sanitisation function can't be optimised out. NB: We only do
344 * this for >2Kb so the overhead doesn't bother us. */
345 if (ret && (num > 2048)) {
346 extern unsigned char cleanse_ctr;
347 ((unsigned char *)ret)[0] = cleanse_ctr;
348 }
349#endif
350
351 return ret; 334 return ret;
352} 335}
353 336
354char 337char *
355*CRYPTO_strdup(const char *str, const char *file, int line) 338CRYPTO_strdup(const char *str, const char *file, int line)
356{ 339{
357 size_t len = strlen(str) + 1; 340 size_t len = strlen(str) + 1;
358 char *ret = CRYPTO_malloc(len, file, line); 341 char *ret = CRYPTO_malloc(len, file, line);
@@ -361,8 +344,8 @@ char
361 return ret; 344 return ret;
362} 345}
363 346
364void 347void *
365*CRYPTO_realloc(void *str, int num, const char *file, int line) 348CRYPTO_realloc(void *str, int num, const char *file, int line)
366{ 349{
367 void *ret = NULL; 350 void *ret = NULL;
368 351
@@ -384,8 +367,8 @@ void
384 return ret; 367 return ret;
385} 368}
386 369
387void 370void *
388*CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, 371CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
389int line) 372int line)
390{ 373{
391 void *ret = NULL; 374 void *ret = NULL;
@@ -433,8 +416,8 @@ CRYPTO_free(void *str)
433 free_debug_func(NULL, 1); 416 free_debug_func(NULL, 1);
434} 417}
435 418
436void 419void *
437*CRYPTO_remalloc(void *a, int num, const char *file, int line) 420CRYPTO_remalloc(void *a, int num, const char *file, int line)
438{ 421{
439 if (a != NULL) 422 if (a != NULL)
440 OPENSSL_free(a); 423 OPENSSL_free(a);