relpEngineDestruct never returns when multiple instances of relpEngine are used
dgouarin opened this issue · 0 comments
dgouarin commented
Hello,
to reproduce this issue, build a rsyslog configuration with both plugins imrelp and omrelp, and compile librelp with openssl.
kill rsyslogd : stuck on omrelp (or imrelp) module unloading.
Upon exit, relpEngineDestruct will be called twice, once for each plugin. When libssl is used instead of gnutls, this cause SSL_CTX_free to be called twice, resulting in a hang.
Fixed by attached patch :
Signed-off-by: David GOUARIN <david.gouarin@thalesgroup.com>
diff -Naur librelp-1.10.0/src/tcp.c librelp-1.10.0.patched/src/tcp.c
--- librelp-1.10.0/src/tcp.c 2021-02-16 09:07:24.000000000 +0100
+++ librelp-1.10.0.patched/src/tcp.c 2021-09-06 12:15:30.469464216 +0200
@@ -1928,8 +1928,10 @@
relpTcpExitTLS_ossl(void)
{
if(called_openssl_global_init == 1) {
- if (ctx != NULL)
+ if (ctx != NULL) {
SSL_CTX_free(ctx);
+ ctx = NULL;
+ }
ENGINE_cleanup();
ERR_free_strings();
EVP_cleanup();
Regards.