Avoid dclose(RTLD_NEXT)
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 10 Nov 2022 18:36:29 +0000 (18:36 +0000)
committerAndreas Schneider <asn@samba.org>
Thu, 24 Nov 2022 06:11:55 +0000 (07:11 +0100)
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: Stefan Metzmacher <metze@samba.org>
src/socket_wrapper.c

index ec8321fe0afcf35660e39a2954e7f342f530d9cc..aefd526ddfe633f4e158138534a0d0b8d6ea3095 100644 (file)
@@ -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);
        }
 }