swrap: Don't do a deep bind if we run with libasan
authorAndreas Schneider <asn@samba.org>
Sat, 1 Sep 2018 17:36:19 +0000 (19:36 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 23 Oct 2018 13:39:17 +0000 (15:39 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
src/socket_wrapper.c

index 3f027dce5420085e5adfe5040ac9f0334e7ff63e..0f19b95d7abbc743d8841789abdc94a99a927719 100644 (file)
@@ -558,7 +558,15 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
        int i;
 
 #ifdef RTLD_DEEPBIND
-       flags |= RTLD_DEEPBIND;
+       const char *env = getenv("LD_PRELOAD");
+
+       /* Don't do a deepbind if we run with libasan */
+       if (env != NULL && strlen(env) < 1024) {
+               const char *p = strstr(env, "libasan.so");
+               if (p == NULL) {
+                       flags |= RTLD_DEEPBIND;
+               }
+       }
 #endif
 
        switch (lib) {