2
0

OSSL_ERR_STATE_save.pod 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. =pod
  2. =head1 NAME
  3. OSSL_ERR_STATE_new, OSSL_ERR_STATE_save, OSSL_ERR_STATE_save_to_mark,
  4. OSSL_ERR_STATE_restore, OSSL_ERR_STATE_free - saving and restoring error state
  5. =head1 SYNOPSIS
  6. #include <openssl/err.h>
  7. ERR_STATE *OSSL_ERR_STATE_new(void);
  8. void OSSL_ERR_STATE_save(ERR_STATE *es);
  9. void OSSL_ERR_STATE_save_to_mark(ERR_STATE *es);
  10. void OSSL_ERR_STATE_restore(const ERR_STATE *es);
  11. void OSSL_ERR_STATE_free(ERR_STATE *es);
  12. =head1 DESCRIPTION
  13. These functions save and restore the error state from the thread
  14. local error state to a preallocated error state structure.
  15. OSSL_ERR_STATE_new() allocates an empty error state structure to
  16. be used when saving and restoring thread error state.
  17. OSSL_ERR_STATE_save() saves the thread error state to I<es>. It
  18. subsequently clears the thread error state. Any previously saved
  19. state in I<es> is cleared prior to saving the new state.
  20. OSSL_ERR_STATE_save_to_mark() is similar to OSSL_ERR_STATE_save() but only saves
  21. ERR entries up to the most recent mark on the ERR stack. These entries are moved
  22. to I<es> and removed from the thread error state. However, the most recent
  23. marked ERR and any ERR state before it remains part of the thread error state
  24. and is not moved to the ERR_STATE. The mark is not cleared and must be cleared
  25. explicitly after a call to this function using L<ERR_pop_to_mark(3)> or
  26. L<ERR_clear_last_mark(3)>. (Since a call to OSSL_ERR_STATE_save_to_mark() leaves
  27. the marked ERR as the top error, either of these functions will have the same
  28. effect.) If there is no marked ERR in the thread local error state, all ERR
  29. entries are copied and the effect is the same as for a call to
  30. OSSL_ERR_STATE_save().
  31. OSSL_ERR_STATE_restore() adds all the error entries from the
  32. saved state I<es> to the thread error state. Existing entries in
  33. the thread error state are not affected if there is enough space
  34. for all the added entries. Any allocated data in the saved error
  35. entries is duplicated on adding to the thread state.
  36. OSSL_ERR_STATE_free() frees the saved error state I<es>.
  37. =head1 RETURN VALUES
  38. OSSL_ERR_STATE_new() returns a pointer to the allocated ERR_STATE
  39. structure or NULL on error.
  40. OSSL_ERR_STATE_save(), OSSL_ERR_STATE_save_to_mark(), OSSL_ERR_STATE_restore(),
  41. OSSL_ERR_STATE_free() do not return any values.
  42. =head1 NOTES
  43. OSSL_ERR_STATE_save() and OSSL_ERR_STATE_save_to_mark() cannot fail as it takes
  44. over any allocated data from the thread error state.
  45. OSSL_ERR_STATE_restore() is a best effort function. The only failure
  46. that can happen during its operation is when memory allocation fails.
  47. Because it manipulates the thread error state it avoids raising memory
  48. errors on such failure. At worst the restored error entries will be
  49. missing the auxiliary error data.
  50. =head1 SEE ALSO
  51. L<ERR_raise(3)>, L<ERR_get_error(3)>, L<ERR_clear_error(3)>
  52. =head1 HISTORY
  53. All of these functions were added in OpenSSL 3.2.
  54. =head1 COPYRIGHT
  55. Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
  56. Licensed under the Apache License 2.0 (the "License"). You may not use
  57. this file except in compliance with the License. You can obtain a copy
  58. in the file LICENSE in the source distribution or at
  59. L<https://www.openssl.org/source/license.html>.
  60. =cut