diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 207 |
1 files changed, 65 insertions, 142 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index d8ad4f8bab..3babdb3211 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: err.c,v 1.63 2024/08/31 10:09:15 tb Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.64 2024/10/02 14:54:26 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -238,87 +238,24 @@ static ERR_STRING_DATA ERR_str_reasons[] = { | |||
| 238 | }; | 238 | }; |
| 239 | #endif | 239 | #endif |
| 240 | 240 | ||
| 241 | 241 | /* | |
| 242 | /* Define the predeclared (but externally opaque) "ERR_FNS" type */ | 242 | * The internal state used by "err_defaults" - as such, the setting, reading, |
| 243 | struct st_ERR_FNS { | ||
| 244 | /* Works on the "error_hash" string table */ | ||
| 245 | LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); | ||
| 246 | void (*cb_err_del)(void); | ||
| 247 | const ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *); | ||
| 248 | const ERR_STRING_DATA *(*cb_err_set_item)(const ERR_STRING_DATA *); | ||
| 249 | const ERR_STRING_DATA *(*cb_err_del_item)(const ERR_STRING_DATA *); | ||
| 250 | /* Works on the "thread_hash" error-state table */ | ||
| 251 | LHASH_OF(ERR_STATE) *(*cb_thread_get)(int create); | ||
| 252 | void (*cb_thread_release)(LHASH_OF(ERR_STATE) **hash); | ||
| 253 | ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *); | ||
| 254 | ERR_STATE *(*cb_thread_set_item)(ERR_STATE *); | ||
| 255 | void (*cb_thread_del_item)(const ERR_STATE *); | ||
| 256 | /* Returns the next available error "library" numbers */ | ||
| 257 | int (*cb_get_next_lib)(void); | ||
| 258 | }; | ||
| 259 | |||
| 260 | /* Predeclarations of the "err_defaults" functions */ | ||
| 261 | static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); | ||
| 262 | static void int_err_del(void); | ||
| 263 | static const ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *); | ||
| 264 | static const ERR_STRING_DATA *int_err_set_item(const ERR_STRING_DATA *); | ||
| 265 | static const ERR_STRING_DATA *int_err_del_item(const ERR_STRING_DATA *); | ||
| 266 | static LHASH_OF(ERR_STATE) *int_thread_get(int create); | ||
| 267 | static void int_thread_release(LHASH_OF(ERR_STATE) **hash); | ||
| 268 | static ERR_STATE *int_thread_get_item(const ERR_STATE *); | ||
| 269 | static ERR_STATE *int_thread_set_item(ERR_STATE *); | ||
| 270 | static void int_thread_del_item(const ERR_STATE *); | ||
| 271 | static int int_err_get_next_lib(void); | ||
| 272 | |||
| 273 | /* The static ERR_FNS table using these defaults functions */ | ||
| 274 | static const ERR_FNS err_defaults = { | ||
| 275 | int_err_get, | ||
| 276 | int_err_del, | ||
| 277 | int_err_get_item, | ||
| 278 | int_err_set_item, | ||
| 279 | int_err_del_item, | ||
| 280 | int_thread_get, | ||
| 281 | int_thread_release, | ||
| 282 | int_thread_get_item, | ||
| 283 | int_thread_set_item, | ||
| 284 | int_thread_del_item, | ||
| 285 | int_err_get_next_lib | ||
| 286 | }; | ||
| 287 | |||
| 288 | /* The replacable table of ERR_FNS functions we use at run-time */ | ||
| 289 | static const ERR_FNS *err_fns = NULL; | ||
| 290 | |||
| 291 | /* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */ | ||
| 292 | #define ERRFN(a) err_fns->cb_##a | ||
| 293 | |||
| 294 | /* The internal state used by "err_defaults" - as such, the setting, reading, | ||
| 295 | * creating, and deleting of this data should only be permitted via the | 243 | * creating, and deleting of this data should only be permitted via the |
| 296 | * "err_defaults" functions. This way, a linked module can completely defer all | 244 | * "err_defaults" functions. This way, a linked module can completely defer all |
| 297 | * ERR state operation (together with requisite locking) to the implementations | 245 | * ERR state operation (together with requisite locking) to the implementations |
| 298 | * and state in the loading application. */ | 246 | * and state in the loading application. |
| 299 | static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; | 247 | */ |
| 300 | static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; | 248 | static LHASH_OF(ERR_STRING_DATA) *err_error_hash = NULL; |
| 301 | static int int_thread_hash_references = 0; | 249 | static LHASH_OF(ERR_STATE) *err_thread_hash = NULL; |
| 302 | static int int_err_library_number = ERR_LIB_USER; | 250 | static int err_thread_hash_references = 0; |
| 251 | static int err_library_number = ERR_LIB_USER; | ||
| 303 | 252 | ||
| 304 | static pthread_t err_init_thread; | 253 | static pthread_t err_init_thread; |
| 305 | 254 | ||
| 306 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | 255 | /* |
| 307 | * the defaults. */ | 256 | * These are the callbacks provided to "lh_new()" when creating the LHASH tables |
| 308 | static void | 257 | * internal to the "err_defaults" implementation. |
| 309 | err_fns_check(void) | 258 | */ |
| 310 | { | ||
| 311 | if (err_fns) | ||
| 312 | return; | ||
| 313 | |||
| 314 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | ||
| 315 | if (!err_fns) | ||
| 316 | err_fns = &err_defaults; | ||
| 317 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | ||
| 318 | } | ||
| 319 | |||
| 320 | /* These are the callbacks provided to "lh_new()" when creating the LHASH tables | ||
| 321 | * internal to the "err_defaults" implementation. */ | ||
| 322 | 259 | ||
| 323 | static unsigned long get_error_values(int inc, int top, const char **file, | 260 | static unsigned long get_error_values(int inc, int top, const char **file, |
| 324 | int *line, const char **data, int *flags); | 261 | int *line, const char **data, int *flags); |
| @@ -344,39 +281,38 @@ err_string_data_cmp(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b) | |||
| 344 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) | 281 | static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) |
| 345 | 282 | ||
| 346 | static LHASH_OF(ERR_STRING_DATA) * | 283 | static LHASH_OF(ERR_STRING_DATA) * |
| 347 | int_err_get(int create) | 284 | err_get(int create) |
| 348 | { | 285 | { |
| 349 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; | 286 | LHASH_OF(ERR_STRING_DATA) *ret = NULL; |
| 350 | 287 | ||
| 351 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 288 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 352 | if (!int_error_hash && create) | 289 | if (!err_error_hash && create) |
| 353 | int_error_hash = lh_ERR_STRING_DATA_new(); | 290 | err_error_hash = lh_ERR_STRING_DATA_new(); |
| 354 | if (int_error_hash) | 291 | if (err_error_hash) |
| 355 | ret = int_error_hash; | 292 | ret = err_error_hash; |
| 356 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 293 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 357 | 294 | ||
| 358 | return ret; | 295 | return ret; |
| 359 | } | 296 | } |
| 360 | 297 | ||
| 361 | static void | 298 | static void |
| 362 | int_err_del(void) | 299 | err_del(void) |
| 363 | { | 300 | { |
| 364 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 301 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 365 | if (int_error_hash) { | 302 | if (err_error_hash) { |
| 366 | lh_ERR_STRING_DATA_free(int_error_hash); | 303 | lh_ERR_STRING_DATA_free(err_error_hash); |
| 367 | int_error_hash = NULL; | 304 | err_error_hash = NULL; |
| 368 | } | 305 | } |
| 369 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 306 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 370 | } | 307 | } |
| 371 | 308 | ||
| 372 | static const ERR_STRING_DATA * | 309 | static const ERR_STRING_DATA * |
| 373 | int_err_get_item(const ERR_STRING_DATA *d) | 310 | err_get_item(const ERR_STRING_DATA *d) |
| 374 | { | 311 | { |
| 375 | ERR_STRING_DATA *p; | 312 | ERR_STRING_DATA *p; |
| 376 | LHASH_OF(ERR_STRING_DATA) *hash; | 313 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 377 | 314 | ||
| 378 | err_fns_check(); | 315 | hash = err_get(0); |
| 379 | hash = ERRFN(err_get)(0); | ||
| 380 | if (!hash) | 316 | if (!hash) |
| 381 | return NULL; | 317 | return NULL; |
| 382 | 318 | ||
| @@ -388,13 +324,12 @@ int_err_get_item(const ERR_STRING_DATA *d) | |||
| 388 | } | 324 | } |
| 389 | 325 | ||
| 390 | static const ERR_STRING_DATA * | 326 | static const ERR_STRING_DATA * |
| 391 | int_err_set_item(const ERR_STRING_DATA *d) | 327 | err_set_item(const ERR_STRING_DATA *d) |
| 392 | { | 328 | { |
| 393 | const ERR_STRING_DATA *p; | 329 | const ERR_STRING_DATA *p; |
| 394 | LHASH_OF(ERR_STRING_DATA) *hash; | 330 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 395 | 331 | ||
| 396 | err_fns_check(); | 332 | hash = err_get(1); |
| 397 | hash = ERRFN(err_get)(1); | ||
| 398 | if (!hash) | 333 | if (!hash) |
| 399 | return NULL; | 334 | return NULL; |
| 400 | 335 | ||
| @@ -406,13 +341,12 @@ int_err_set_item(const ERR_STRING_DATA *d) | |||
| 406 | } | 341 | } |
| 407 | 342 | ||
| 408 | static const ERR_STRING_DATA * | 343 | static const ERR_STRING_DATA * |
| 409 | int_err_del_item(const ERR_STRING_DATA *d) | 344 | err_del_item(const ERR_STRING_DATA *d) |
| 410 | { | 345 | { |
| 411 | ERR_STRING_DATA *p; | 346 | ERR_STRING_DATA *p; |
| 412 | LHASH_OF(ERR_STRING_DATA) *hash; | 347 | LHASH_OF(ERR_STRING_DATA) *hash; |
| 413 | 348 | ||
| 414 | err_fns_check(); | 349 | hash = err_get(0); |
| 415 | hash = ERRFN(err_get)(0); | ||
| 416 | if (!hash) | 350 | if (!hash) |
| 417 | return NULL; | 351 | return NULL; |
| 418 | 352 | ||
| @@ -438,30 +372,30 @@ err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) | |||
| 438 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) | 372 | static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) |
| 439 | 373 | ||
| 440 | static LHASH_OF(ERR_STATE) * | 374 | static LHASH_OF(ERR_STATE) * |
| 441 | int_thread_get(int create) | 375 | err_thread_get(int create) |
| 442 | { | 376 | { |
| 443 | LHASH_OF(ERR_STATE) *ret = NULL; | 377 | LHASH_OF(ERR_STATE) *ret = NULL; |
| 444 | 378 | ||
| 445 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 379 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 446 | if (!int_thread_hash && create) | 380 | if (!err_thread_hash && create) |
| 447 | int_thread_hash = lh_ERR_STATE_new(); | 381 | err_thread_hash = lh_ERR_STATE_new(); |
| 448 | if (int_thread_hash) { | 382 | if (err_thread_hash) { |
| 449 | int_thread_hash_references++; | 383 | err_thread_hash_references++; |
| 450 | ret = int_thread_hash; | 384 | ret = err_thread_hash; |
| 451 | } | 385 | } |
| 452 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 386 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 453 | return ret; | 387 | return ret; |
| 454 | } | 388 | } |
| 455 | 389 | ||
| 456 | static void | 390 | static void |
| 457 | int_thread_release(LHASH_OF(ERR_STATE) **hash) | 391 | err_thread_release(LHASH_OF(ERR_STATE) **hash) |
| 458 | { | 392 | { |
| 459 | int i; | 393 | int i; |
| 460 | 394 | ||
| 461 | if (hash == NULL || *hash == NULL) | 395 | if (hash == NULL || *hash == NULL) |
| 462 | return; | 396 | return; |
| 463 | 397 | ||
| 464 | i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); | 398 | i = CRYPTO_add(&err_thread_hash_references, -1, CRYPTO_LOCK_ERR); |
| 465 | if (i > 0) | 399 | if (i > 0) |
| 466 | return; | 400 | return; |
| 467 | 401 | ||
| @@ -469,13 +403,12 @@ int_thread_release(LHASH_OF(ERR_STATE) **hash) | |||
| 469 | } | 403 | } |
| 470 | 404 | ||
| 471 | static ERR_STATE * | 405 | static ERR_STATE * |
| 472 | int_thread_get_item(const ERR_STATE *d) | 406 | err_thread_get_item(const ERR_STATE *d) |
| 473 | { | 407 | { |
| 474 | ERR_STATE *p; | 408 | ERR_STATE *p; |
| 475 | LHASH_OF(ERR_STATE) *hash; | 409 | LHASH_OF(ERR_STATE) *hash; |
| 476 | 410 | ||
| 477 | err_fns_check(); | 411 | hash = err_thread_get(0); |
| 478 | hash = ERRFN(thread_get)(0); | ||
| 479 | if (!hash) | 412 | if (!hash) |
| 480 | return NULL; | 413 | return NULL; |
| 481 | 414 | ||
| @@ -483,18 +416,17 @@ int_thread_get_item(const ERR_STATE *d) | |||
| 483 | p = lh_ERR_STATE_retrieve(hash, d); | 416 | p = lh_ERR_STATE_retrieve(hash, d); |
| 484 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); | 417 | CRYPTO_r_unlock(CRYPTO_LOCK_ERR); |
| 485 | 418 | ||
| 486 | ERRFN(thread_release)(&hash); | 419 | err_thread_release(&hash); |
| 487 | return p; | 420 | return p; |
| 488 | } | 421 | } |
| 489 | 422 | ||
| 490 | static ERR_STATE * | 423 | static ERR_STATE * |
| 491 | int_thread_set_item(ERR_STATE *d) | 424 | err_thread_set_item(ERR_STATE *d) |
| 492 | { | 425 | { |
| 493 | ERR_STATE *p; | 426 | ERR_STATE *p; |
| 494 | LHASH_OF(ERR_STATE) *hash; | 427 | LHASH_OF(ERR_STATE) *hash; |
| 495 | 428 | ||
| 496 | err_fns_check(); | 429 | hash = err_thread_get(1); |
| 497 | hash = ERRFN(thread_get)(1); | ||
| 498 | if (!hash) | 430 | if (!hash) |
| 499 | return NULL; | 431 | return NULL; |
| 500 | 432 | ||
| @@ -502,43 +434,42 @@ int_thread_set_item(ERR_STATE *d) | |||
| 502 | p = lh_ERR_STATE_insert(hash, d); | 434 | p = lh_ERR_STATE_insert(hash, d); |
| 503 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 435 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 504 | 436 | ||
| 505 | ERRFN(thread_release)(&hash); | 437 | err_thread_release(&hash); |
| 506 | return p; | 438 | return p; |
| 507 | } | 439 | } |
| 508 | 440 | ||
| 509 | static void | 441 | static void |
| 510 | int_thread_del_item(const ERR_STATE *d) | 442 | err_thread_del_item(const ERR_STATE *d) |
| 511 | { | 443 | { |
| 512 | ERR_STATE *p; | 444 | ERR_STATE *p; |
| 513 | LHASH_OF(ERR_STATE) *hash; | 445 | LHASH_OF(ERR_STATE) *hash; |
| 514 | 446 | ||
| 515 | err_fns_check(); | 447 | hash = err_thread_get(0); |
| 516 | hash = ERRFN(thread_get)(0); | ||
| 517 | if (!hash) | 448 | if (!hash) |
| 518 | return; | 449 | return; |
| 519 | 450 | ||
| 520 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 451 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 521 | p = lh_ERR_STATE_delete(hash, d); | 452 | p = lh_ERR_STATE_delete(hash, d); |
| 522 | /* make sure we don't leak memory */ | 453 | /* make sure we don't leak memory */ |
| 523 | if (int_thread_hash_references == 1 && | 454 | if (err_thread_hash_references == 1 && |
| 524 | int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) { | 455 | err_thread_hash && lh_ERR_STATE_num_items(err_thread_hash) == 0) { |
| 525 | lh_ERR_STATE_free(int_thread_hash); | 456 | lh_ERR_STATE_free(err_thread_hash); |
| 526 | int_thread_hash = NULL; | 457 | err_thread_hash = NULL; |
| 527 | } | 458 | } |
| 528 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 459 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 529 | 460 | ||
| 530 | ERRFN(thread_release)(&hash); | 461 | err_thread_release(&hash); |
| 531 | if (p) | 462 | if (p) |
| 532 | ERR_STATE_free(p); | 463 | ERR_STATE_free(p); |
| 533 | } | 464 | } |
| 534 | 465 | ||
| 535 | static int | 466 | static int |
| 536 | int_err_get_next_lib(void) | 467 | err_get_next_lib(void) |
| 537 | { | 468 | { |
| 538 | int ret; | 469 | int ret; |
| 539 | 470 | ||
| 540 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); | 471 | CRYPTO_w_lock(CRYPTO_LOCK_ERR); |
| 541 | ret = int_err_library_number++; | 472 | ret = err_library_number++; |
| 542 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); | 473 | CRYPTO_w_unlock(CRYPTO_LOCK_ERR); |
| 543 | 474 | ||
| 544 | return ret; | 475 | return ret; |
| @@ -647,7 +578,6 @@ void | |||
| 647 | ERR_load_ERR_strings_internal(void) | 578 | ERR_load_ERR_strings_internal(void) |
| 648 | { | 579 | { |
| 649 | err_init_thread = pthread_self(); | 580 | err_init_thread = pthread_self(); |
| 650 | err_fns_check(); | ||
| 651 | #ifndef OPENSSL_NO_ERR | 581 | #ifndef OPENSSL_NO_ERR |
| 652 | err_load_strings(0, ERR_str_libraries); | 582 | err_load_strings(0, ERR_str_libraries); |
| 653 | err_load_strings(0, ERR_str_reasons); | 583 | err_load_strings(0, ERR_str_reasons); |
| @@ -679,7 +609,7 @@ err_load_strings(int lib, ERR_STRING_DATA *str) | |||
| 679 | while (str->error) { | 609 | while (str->error) { |
| 680 | if (lib) | 610 | if (lib) |
| 681 | str->error |= ERR_PACK(lib, 0, 0); | 611 | str->error |= ERR_PACK(lib, 0, 0); |
| 682 | ERRFN(err_set_item)(str); | 612 | err_set_item(str); |
| 683 | str++; | 613 | str++; |
| 684 | } | 614 | } |
| 685 | } | 615 | } |
| @@ -697,7 +627,7 @@ ERR_load_const_strings(const ERR_STRING_DATA *str) | |||
| 697 | { | 627 | { |
| 698 | ERR_load_ERR_strings(); | 628 | ERR_load_ERR_strings(); |
| 699 | while (str->error) { | 629 | while (str->error) { |
| 700 | ERRFN(err_set_item)(str); | 630 | err_set_item(str); |
| 701 | str++; | 631 | str++; |
| 702 | } | 632 | } |
| 703 | } | 633 | } |
| @@ -711,7 +641,7 @@ ERR_unload_strings(int lib, ERR_STRING_DATA *str) | |||
| 711 | while (str->error) { | 641 | while (str->error) { |
| 712 | if (lib) | 642 | if (lib) |
| 713 | str->error |= ERR_PACK(lib, 0, 0); | 643 | str->error |= ERR_PACK(lib, 0, 0); |
| 714 | ERRFN(err_del_item)(str); | 644 | err_del_item(str); |
| 715 | str++; | 645 | str++; |
| 716 | } | 646 | } |
| 717 | } | 647 | } |
| @@ -723,8 +653,7 @@ ERR_free_strings(void) | |||
| 723 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | 653 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ |
| 724 | (void) OPENSSL_init_crypto(0, NULL); | 654 | (void) OPENSSL_init_crypto(0, NULL); |
| 725 | 655 | ||
| 726 | err_fns_check(); | 656 | err_del(); |
| 727 | ERRFN(err_del)(); | ||
| 728 | } | 657 | } |
| 729 | LCRYPTO_ALIAS(ERR_free_strings); | 658 | LCRYPTO_ALIAS(ERR_free_strings); |
| 730 | 659 | ||
| @@ -981,10 +910,9 @@ ERR_lib_error_string(unsigned long e) | |||
| 981 | if (!OPENSSL_init_crypto(0, NULL)) | 910 | if (!OPENSSL_init_crypto(0, NULL)) |
| 982 | return NULL; | 911 | return NULL; |
| 983 | 912 | ||
| 984 | err_fns_check(); | ||
| 985 | l = ERR_GET_LIB(e); | 913 | l = ERR_GET_LIB(e); |
| 986 | d.error = ERR_PACK(l, 0, 0); | 914 | d.error = ERR_PACK(l, 0, 0); |
| 987 | p = ERRFN(err_get_item)(&d); | 915 | p = err_get_item(&d); |
| 988 | return ((p == NULL) ? NULL : p->string); | 916 | return ((p == NULL) ? NULL : p->string); |
| 989 | } | 917 | } |
| 990 | LCRYPTO_ALIAS(ERR_lib_error_string); | 918 | LCRYPTO_ALIAS(ERR_lib_error_string); |
| @@ -996,11 +924,10 @@ ERR_func_error_string(unsigned long e) | |||
| 996 | ERR_STRING_DATA d; | 924 | ERR_STRING_DATA d; |
| 997 | unsigned long l, f; | 925 | unsigned long l, f; |
| 998 | 926 | ||
| 999 | err_fns_check(); | ||
| 1000 | l = ERR_GET_LIB(e); | 927 | l = ERR_GET_LIB(e); |
| 1001 | f = ERR_GET_FUNC(e); | 928 | f = ERR_GET_FUNC(e); |
| 1002 | d.error = ERR_PACK(l, f, 0); | 929 | d.error = ERR_PACK(l, f, 0); |
| 1003 | p = ERRFN(err_get_item)(&d); | 930 | p = err_get_item(&d); |
| 1004 | return ((p == NULL) ? NULL : p->string); | 931 | return ((p == NULL) ? NULL : p->string); |
| 1005 | } | 932 | } |
| 1006 | LCRYPTO_ALIAS(ERR_func_error_string); | 933 | LCRYPTO_ALIAS(ERR_func_error_string); |
| @@ -1012,14 +939,13 @@ ERR_reason_error_string(unsigned long e) | |||
| 1012 | ERR_STRING_DATA d; | 939 | ERR_STRING_DATA d; |
| 1013 | unsigned long l, r; | 940 | unsigned long l, r; |
| 1014 | 941 | ||
| 1015 | err_fns_check(); | ||
| 1016 | l = ERR_GET_LIB(e); | 942 | l = ERR_GET_LIB(e); |
| 1017 | r = ERR_GET_REASON(e); | 943 | r = ERR_GET_REASON(e); |
| 1018 | d.error = ERR_PACK(l, 0, r); | 944 | d.error = ERR_PACK(l, 0, r); |
| 1019 | p = ERRFN(err_get_item)(&d); | 945 | p = err_get_item(&d); |
| 1020 | if (!p) { | 946 | if (!p) { |
| 1021 | d.error = ERR_PACK(0, 0, r); | 947 | d.error = ERR_PACK(0, 0, r); |
| 1022 | p = ERRFN(err_get_item)(&d); | 948 | p = err_get_item(&d); |
| 1023 | } | 949 | } |
| 1024 | return ((p == NULL) ? NULL : p->string); | 950 | return ((p == NULL) ? NULL : p->string); |
| 1025 | } | 951 | } |
| @@ -1034,10 +960,9 @@ ERR_remove_thread_state(const CRYPTO_THREADID *id) | |||
| 1034 | CRYPTO_THREADID_cpy(&tmp.tid, id); | 960 | CRYPTO_THREADID_cpy(&tmp.tid, id); |
| 1035 | else | 961 | else |
| 1036 | CRYPTO_THREADID_current(&tmp.tid); | 962 | CRYPTO_THREADID_current(&tmp.tid); |
| 1037 | err_fns_check(); | 963 | /* err_thread_del_item automatically destroys the LHASH if the number of |
| 1038 | /* thread_del_item automatically destroys the LHASH if the number of | ||
| 1039 | * items reaches zero. */ | 964 | * items reaches zero. */ |
| 1040 | ERRFN(thread_del_item)(&tmp); | 965 | err_thread_del_item(&tmp); |
| 1041 | } | 966 | } |
| 1042 | LCRYPTO_ALIAS(ERR_remove_thread_state); | 967 | LCRYPTO_ALIAS(ERR_remove_thread_state); |
| 1043 | 968 | ||
| @@ -1056,10 +981,9 @@ ERR_get_state(void) | |||
| 1056 | int i; | 981 | int i; |
| 1057 | CRYPTO_THREADID tid; | 982 | CRYPTO_THREADID tid; |
| 1058 | 983 | ||
| 1059 | err_fns_check(); | ||
| 1060 | CRYPTO_THREADID_current(&tid); | 984 | CRYPTO_THREADID_current(&tid); |
| 1061 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); | 985 | CRYPTO_THREADID_cpy(&tmp.tid, &tid); |
| 1062 | ret = ERRFN(thread_get_item)(&tmp); | 986 | ret = err_thread_get_item(&tmp); |
| 1063 | 987 | ||
| 1064 | /* ret == the error state, if NULL, make a new one */ | 988 | /* ret == the error state, if NULL, make a new one */ |
| 1065 | if (ret == NULL) { | 989 | if (ret == NULL) { |
| @@ -1073,9 +997,9 @@ ERR_get_state(void) | |||
| 1073 | ret->err_data[i] = NULL; | 997 | ret->err_data[i] = NULL; |
| 1074 | ret->err_data_flags[i] = 0; | 998 | ret->err_data_flags[i] = 0; |
| 1075 | } | 999 | } |
| 1076 | tmpp = ERRFN(thread_set_item)(ret); | 1000 | tmpp = err_thread_set_item(ret); |
| 1077 | /* To check if insertion failed, do a get. */ | 1001 | /* To check if insertion failed, do a get. */ |
| 1078 | if (ERRFN(thread_get_item)(ret) != ret) { | 1002 | if (err_thread_get_item(ret) != ret) { |
| 1079 | ERR_STATE_free(ret); /* could not insert it */ | 1003 | ERR_STATE_free(ret); /* could not insert it */ |
| 1080 | return (&fallback); | 1004 | return (&fallback); |
| 1081 | } | 1005 | } |
| @@ -1090,8 +1014,7 @@ ERR_get_state(void) | |||
| 1090 | int | 1014 | int |
| 1091 | ERR_get_next_error_library(void) | 1015 | ERR_get_next_error_library(void) |
| 1092 | { | 1016 | { |
| 1093 | err_fns_check(); | 1017 | return err_get_next_lib(); |
| 1094 | return ERRFN(get_next_lib)(); | ||
| 1095 | } | 1018 | } |
| 1096 | LCRYPTO_ALIAS(ERR_get_next_error_library); | 1019 | LCRYPTO_ALIAS(ERR_get_next_error_library); |
| 1097 | 1020 | ||
