1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
From dbfc9e2c2f53041e10b470ed29cab9af784ae00b Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu, 10 Nov 2022 18:38:17 +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 <samuel.thibault@ens-lyon.org>
https://bugzilla.samba.org/show_bug.cgi?id=15228
---
src/nss_wrapper.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 07c9757..b95afdf 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -6499,13 +6499,25 @@ void nwrap_destructor(void)
/* libc */
if (m->libc != NULL) {
- if (m->libc->handle != NULL) {
+ if (m->libc->handle != NULL
+#ifdef RTLD_NEXT
+ && m->libc->handle != RTLD_NEXT
+#endif
+ ) {
dlclose(m->libc->handle);
}
- if (m->libc->nsl_handle != NULL) {
+ if (m->libc->nsl_handle != NULL
+#ifdef RTLD_NEXT
+ && m->libc->nsl_handle != RTLD_NEXT
+#endif
+ ) {
dlclose(m->libc->nsl_handle);
}
- if (m->libc->sock_handle != NULL) {
+ if (m->libc->sock_handle != NULL
+#ifdef RTLD_NEXT
+ && m->libc->sock_handle != RTLD_NEXT
+#endif
+ ) {
dlclose(m->libc->sock_handle);
}
SAFE_FREE(m->libc);
--
GitLab
|