diff options
| author | matthew <> | 2014-04-16 01:35:37 +0000 |
|---|---|---|
| committer | matthew <> | 2014-04-16 01:35:37 +0000 |
| commit | b004a0e4fa3e34864fa037337f997c9f4fcae800 (patch) | |
| tree | f2d923e3b9b114440b806c525ecbfc5a8631b3d1 /src/lib/libcrypto/mem.c | |
| parent | 888a8ada3c0848b5d246511c1df5246e84fe0e45 (diff) | |
| download | openbsd-b004a0e4fa3e34864fa037337f997c9f4fcae800.tar.gz openbsd-b004a0e4fa3e34864fa037337f997c9f4fcae800.tar.bz2 openbsd-b004a0e4fa3e34864fa037337f997c9f4fcae800.zip | |
Remove disabled code that wouldn't work now that cleanse_ptr was
removed.
Also, fix some nearby KNF nits that were bothering me.
ok beck
Diffstat (limited to 'src/lib/libcrypto/mem.c')
| -rw-r--r-- | src/lib/libcrypto/mem.c | 53 |
1 files changed, 18 insertions, 35 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 | ||
| 183 | int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), | 183 | int |
| 184 | CRYPTO_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 | ||
| 225 | void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), | 226 | void |
| 227 | CRYPTO_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 | ||
| 247 | void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), | 249 | void |
| 250 | CRYPTO_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 | ||
| 275 | void | 278 | void * |
| 276 | *CRYPTO_malloc_locked(int num, const char *file, int line) | 279 | CRYPTO_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 | ||
| 321 | void | 314 | void * |
| 322 | *CRYPTO_malloc(int num, const char *file, int line) | 315 | CRYPTO_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 | ||
| 354 | char | 337 | char * |
| 355 | *CRYPTO_strdup(const char *str, const char *file, int line) | 338 | CRYPTO_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 | ||
| 364 | void | 347 | void * |
| 365 | *CRYPTO_realloc(void *str, int num, const char *file, int line) | 348 | CRYPTO_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 | ||
| 387 | void | 370 | void * |
| 388 | *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, | 371 | CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, |
| 389 | int line) | 372 | int 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 | ||
| 436 | void | 419 | void * |
| 437 | *CRYPTO_remalloc(void *a, int num, const char *file, int line) | 420 | CRYPTO_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); |
