aboutsummaryrefslogtreecommitdiff
path: root/crypto/err
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-12-14 19:33:55 +0100
committerRichard Levitte <levitte@openssl.org>2018-12-14 19:33:55 +0100
commit91c5473035aaf2c0d86e4039c2a29a5b70541905 (patch)
tree5141a7d7322d4ad3e3bce979a7669582fa1d5d2b /crypto/err
parent9a3b5b766421b7ed9df859956d44fcbe52c2dd82 (diff)
downloadopenssl-91c5473035aaf2c0d86e4039c2a29a5b70541905.zip
openssl-91c5473035aaf2c0d86e4039c2a29a5b70541905.tar.gz
openssl-91c5473035aaf2c0d86e4039c2a29a5b70541905.tar.bz2
ERR: preserve system error number in a few more places
It turns out that intialization may change the error number, so we need to preserve the system error number in functions where initialization is called for. These are ERR_get_state() and err_shelve_state() Fixes #7897 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7902)
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index bc671c9..c80aa6b 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -697,6 +697,7 @@ DEFINE_RUN_ONCE_STATIC(err_do_init)
ERR_STATE *ERR_get_state(void)
{
ERR_STATE *state;
+ int saveerrno = get_last_sys_error();
if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
return NULL;
@@ -728,6 +729,7 @@ ERR_STATE *ERR_get_state(void)
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
}
+ set_sys_error(saveerrno);
return state;
}
@@ -737,6 +739,8 @@ ERR_STATE *ERR_get_state(void)
*/
int err_shelve_state(void **state)
{
+ int saveerrno = get_last_sys_error();
+
if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
return 0;
@@ -747,6 +751,7 @@ int err_shelve_state(void **state)
if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
return 0;
+ set_sys_error(saveerrno);
return 1;
}