OSSL_ERR_STATE_SAVE(3ossl)
π OSSL_ERR_STATE_SAVE β saving and restoring error state π
okay bestie, so this is the OpenSSL page for OSSL_ERR_STATE_SAVE(3ossl) and it's literally all about β¨saving and restoring your error stateβ¨ like it's a video game checkpoint. no cap.
β¨ NAME β¨
OSSL_ERR_STATE_new, OSSL_ERR_STATE_save, OSSL_ERR_STATE_save_to_mark, OSSL_ERR_STATE_restore, OSSL_ERR_STATE_free β saving and restoring error state π
πΈ SYNOPSIS πΈ
#include <openssl/err.h>
ERR_STATE *OSSL_ERR_STATE_new(void);
void OSSL_ERR_STATE_save(ERR_STATE *es);
void OSSL_ERR_STATE_save_to_mark(ERR_STATE *es);
void OSSL_ERR_STATE_restore(const ERR_STATE *es);
void OSSL_ERR_STATE_free(ERR_STATE *es);
π DESCRIPTION π
so the whole vibe here is: these functions save and restore the error state from the thread local error state into a preallocated error state structure. it's giving snapshot and rollback, bestie. πΈ
OSSL_ERR_STATE_new()β allocates an empty error state structure, which you then use when saving and restoring thread error state. fresh start energy π¦OSSL_ERR_STATE_save()β saves the thread error state intoes. and then? it clears the thread error state. gone. bye. π also, whatever was previously saved inesgets cleared before the new state is saved, so no stale leftovers, we don't do that here.OSSL_ERR_STATE_save_to_mark()β similar toOSSL_ERR_STATE_save()but with a little twist β¨ it only savesERRentries up to the most recent mark on theERRstack. those entries get moved toesand removed from the thread error state. BUT (and this is the important part, don't skip it π) the most recent markedERRand anyERRstate before it stays part of the thread error state and does not get moved to theERR_STATE. the mark is not cleared, and it must be cleared explicitly after a call to this function, usingERR_pop_to_mark(3)orERR_clear_last_mark(3). and since a call toOSSL_ERR_STATE_save_to_mark()leaves the markedERRas the top error, either of those functions will have the same effect. iykyk. and if there's no markedERRin the thread local error state? then allERRentries are copied and the effect is the same as a call toOSSL_ERR_STATE_save(). easy.OSSL_ERR_STATE_restore()β adds all the error entries from the saved stateesto the thread error state. existing entries in the thread error state are not affected if there's enough space for all the added entries. and any allocated data in the saved error entries gets duplicated when adding to the thread state. copy-paste but make it official π«ΆOSSL_ERR_STATE_free()β frees the saved error statees. and if the argument isNULL? nothing happens. no drama, no crash, we love a chill function. π
π RETURN VALUES π
OSSL_ERR_STATE_new()returns a pointer to the allocatedERR_STATEstructure, orNULLon error. πOSSL_ERR_STATE_save(),OSSL_ERR_STATE_save_to_mark(),OSSL_ERR_STATE_restore(), andOSSL_ERR_STATE_free()do not return any values. they'revoid, they simply do the thing and leave. main character exit. π
π§ NOTES π§
OSSL_ERR_STATE_save()andOSSL_ERR_STATE_save_to_mark()cannot fail, because they take over any allocated data from the thread error state. slay, no failure mode. β¨OSSL_ERR_STATE_restore()is a best effort function. the only failure that can happen during its operation is when memory allocation fails. and because it manipulates the thread error state, it avoids raising memory errors on such failure. at worst, the restored error entries will be missing the auxiliary error data. so likeβ¦ mostly fine, slightly imperfect, relatable. π
π SEE ALSO π
ERR_raise(3), ERR_get_error(3), ERR_clear_error(3)
β HISTORY β
all of these functions were added in OpenSSL 3.2. so if you're on something older, this is not for you bestie, upgrade. π
π COPYRIGHT π
Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, periodt. π this was OpenSSL 3.5.9, dated 2026-09-29, and it's the OSSL_ERR_STATE_SAVE(3ossl) manual. go forth and save your error state, queen. π¦π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms