aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-05-04 12:51:18 +0100
committerMatt Caswell <matt@openssl.org>2017-05-04 15:51:26 +0100
commit689f112d9806fa4a0c2f8c108226639455bc770d (patch)
tree75fee6d0401ab4b03769f4d8c6b45b7b9c1d5cc0
parentde6ac50ddc6c901d43afcd914a1708f9b87efcf2 (diff)
downloadopenssl-689f112d9806fa4a0c2f8c108226639455bc770d.zip
openssl-689f112d9806fa4a0c2f8c108226639455bc770d.tar.gz
openssl-689f112d9806fa4a0c2f8c108226639455bc770d.tar.bz2
Don't leave stale errors on queue if DSO_dsobyaddr() fails
The init code uses DSO_dsobyaddr() to leak a reference to ourselves to ensure we remain loaded until atexit() time. In some circumstances that can fail and leave stale errors on the error queue. Fixes #3372 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3383)
-rw-r--r--crypto/init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/init.c b/crypto/init.c
index 8036654..265d54d 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -107,13 +107,15 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base)
# else
/*
* Deliberately leak a reference to ourselves. This will force the library
- * to remain loaded until the atexit() handler is run a process exit.
+ * to remain loaded until the atexit() handler is run at process exit.
*/
{
DSO *dso = NULL;
+ ERR_set_mark();
dso = DSO_dsobyaddr(&base_inited, DSO_FLAG_NO_UNLOAD_ON_FREE);
DSO_free(dso);
+ ERR_pop_to_mark();
}
# endif
#endif
@@ -648,8 +650,10 @@ int OPENSSL_atexit(void (*handler)(void))
{
DSO *dso = NULL;
+ ERR_set_mark();
dso = DSO_dsobyaddr(handlersym.sym, DSO_FLAG_NO_UNLOAD_ON_FREE);
DSO_free(dso);
+ ERR_pop_to_mark();
}
# endif
}