diff options
| author | markus <> | 2003-05-11 21:36:58 +0000 |
|---|---|---|
| committer | markus <> | 2003-05-11 21:36:58 +0000 |
| commit | 1c98a87f0daac81245653c227eb2f2508a22a965 (patch) | |
| tree | 3de6d603296ec563b936da4e6a8a1e33d48f8884 /src/lib/libcrypto/cryptlib.c | |
| parent | 31392c89d1135cf2a416f97295f6d21681b3fbc4 (diff) | |
| download | openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.gz openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.bz2 openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.zip | |
import 0.9.7b (without idea and rc5)
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/cryptlib.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index 612b3b93b4..2924def2bb 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
| @@ -89,6 +89,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] = | |||
| 89 | "ssl_session", | 89 | "ssl_session", |
| 90 | "ssl_sess_cert", | 90 | "ssl_sess_cert", |
| 91 | "ssl", | 91 | "ssl", |
| 92 | "ssl_method", | ||
| 92 | "rand", | 93 | "rand", |
| 93 | "rand2", | 94 | "rand2", |
| 94 | "debug_malloc", | 95 | "debug_malloc", |
| @@ -103,7 +104,8 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] = | |||
| 103 | "dynlock", | 104 | "dynlock", |
| 104 | "engine", | 105 | "engine", |
| 105 | "ui", | 106 | "ui", |
| 106 | #if CRYPTO_NUM_LOCKS != 31 | 107 | "hwcrhk", /* This is a HACK which will disappear in 0.9.8 */ |
| 108 | #if CRYPTO_NUM_LOCKS != 33 | ||
| 107 | # error "Inconsistency between crypto.h and cryptlib.c" | 109 | # error "Inconsistency between crypto.h and cryptlib.c" |
| 108 | #endif | 110 | #endif |
| 109 | }; | 111 | }; |
| @@ -206,10 +208,18 @@ int CRYPTO_get_new_dynlockid(void) | |||
| 206 | i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); | 208 | i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); |
| 207 | /* If there was none, push, thereby creating a new one */ | 209 | /* If there was none, push, thereby creating a new one */ |
| 208 | if (i == -1) | 210 | if (i == -1) |
| 209 | i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); | 211 | /* Since sk_push() returns the number of items on the |
| 212 | stack, not the location of the pushed item, we need | ||
| 213 | to transform the returned number into a position, | ||
| 214 | by decreasing it. */ | ||
| 215 | i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1; | ||
| 216 | else | ||
| 217 | /* If we found a place with a NULL pointer, put our pointer | ||
| 218 | in it. */ | ||
| 219 | sk_CRYPTO_dynlock_set(dyn_locks,i,pointer); | ||
| 210 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); | 220 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); |
| 211 | 221 | ||
| 212 | if (!i) | 222 | if (i == -1) |
| 213 | { | 223 | { |
| 214 | dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); | 224 | dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); |
| 215 | OPENSSL_free(pointer); | 225 | OPENSSL_free(pointer); |
| @@ -401,15 +411,17 @@ void CRYPTO_lock(int mode, int type, const char *file, int line) | |||
| 401 | #endif | 411 | #endif |
| 402 | if (type < 0) | 412 | if (type < 0) |
| 403 | { | 413 | { |
| 404 | struct CRYPTO_dynlock_value *pointer | 414 | if (dynlock_lock_callback != NULL) |
| 405 | = CRYPTO_get_dynlock_value(type); | ||
| 406 | |||
| 407 | if (pointer && dynlock_lock_callback) | ||
| 408 | { | 415 | { |
| 416 | struct CRYPTO_dynlock_value *pointer | ||
| 417 | = CRYPTO_get_dynlock_value(type); | ||
| 418 | |||
| 419 | OPENSSL_assert(pointer != NULL); | ||
| 420 | |||
| 409 | dynlock_lock_callback(mode, pointer, file, line); | 421 | dynlock_lock_callback(mode, pointer, file, line); |
| 410 | } | ||
| 411 | 422 | ||
| 412 | CRYPTO_destroy_dynlockid(type); | 423 | CRYPTO_destroy_dynlockid(type); |
| 424 | } | ||
| 413 | } | 425 | } |
| 414 | else | 426 | else |
| 415 | if (locking_callback != NULL) | 427 | if (locking_callback != NULL) |
| @@ -460,7 +472,7 @@ const char *CRYPTO_get_lock_name(int type) | |||
| 460 | return("dynamic"); | 472 | return("dynamic"); |
| 461 | else if (type < CRYPTO_NUM_LOCKS) | 473 | else if (type < CRYPTO_NUM_LOCKS) |
| 462 | return(lock_names[type]); | 474 | return(lock_names[type]); |
| 463 | else if (type-CRYPTO_NUM_LOCKS >= sk_num(app_locks)) | 475 | else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks)) |
| 464 | return("ERROR"); | 476 | return("ERROR"); |
| 465 | else | 477 | else |
| 466 | return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS)); | 478 | return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS)); |
| @@ -492,3 +504,11 @@ BOOL WINAPI DLLEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, | |||
| 492 | #endif | 504 | #endif |
| 493 | 505 | ||
| 494 | #endif | 506 | #endif |
| 507 | |||
| 508 | void OpenSSLDie(const char *file,int line,const char *assertion) | ||
| 509 | { | ||
| 510 | fprintf(stderr, | ||
| 511 | "%s(%d): OpenSSL internal error, assertion failed: %s\n", | ||
| 512 | file,line,assertion); | ||
| 513 | abort(); | ||
| 514 | } | ||
