In case the libc was not found and RTLD_NEXT is used instead, we should not
dlclose it, otherwise mayhem happens.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15228
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
/* 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);