From c3c7d9d68dc91ed6345842dcbbd9e226e78d9177 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 10 Nov 2022 18:36:29 +0000 Subject: [PATCH] Avoid dclose(RTLD_NEXT) In case the libc was not found and RTLD_NEXT is used instead, we should not dlclose it, otherwise mayhem happens. Signed-off-by: Samuel Thibault https://bugzilla.samba.org/show_bug.cgi?id=15228 --- src/socket_wrapper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index ec8321f..cc9e17d 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -7831,10 +7831,18 @@ void swrap_destructor(void) SAFE_FREE(sockets); - if (swrap.libc.handle != NULL) { + if (swrap.libc.handle != NULL +#ifdef RTLD_NEXT + && swrap.libc.handle != RTLD_NEXT +#endif + ) { dlclose(swrap.libc.handle); } - if (swrap.libc.socket_handle) { + if (swrap.libc.socket_handle +#ifdef RTLD_NEXT + && swrap.libc.socket_handle != RTLD_NEXT +#endif + ) { dlclose(swrap.libc.socket_handle); } } -- GitLab