summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0031cb7..d4a565a 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -271,6 +271,7 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
#define LIBC_NAME "libc.so"
+#ifndef HAVE_APPLE
static void *libc_hnd;
static int libc_dlopen(void)
@@ -286,18 +287,12 @@ static int libc_dlopen(void)
return 0;
}
-#ifdef HAVE_APPLE
- if (libc_hnd == NULL) {
- libc_hnd = dlopen("libc.dylib", flags);
- }
-#else
for (libc_hnd = NULL, i = 10; libc_hnd == NULL; i--) {
char soname[256] = {0};
snprintf(soname, sizeof(soname), "%s.%u", LIBC_NAME, i);
libc_hnd = dlopen(soname, flags);
}
-#endif
if (libc_hnd == NULL) {
SWRAP_LOG(SWRAP_LOG_ERROR,
@@ -308,21 +303,21 @@ static int libc_dlopen(void)
return 0;
}
+#endif
static void *libc_dlsym(const char *name)
{
void *func;
- char sym_name[256];
libc_dlopen();
#ifdef HAVE_APPLE
- snprintf(sym_name, sizeof(sym_name), "_%s", name);
+ func = dlsym(RTLD_NEXT, name);
#else
- snprintf(sym_name, sizeof(sym_name), "%s", name);
-#endif
+ libc_dlopen();
- func = dlsym(libc_hnd, sym_name);
+ func = dlsym(libc_hnd, name);
+#endif
if (func == NULL) {
SWRAP_LOG(SWRAP_LOG_ERROR,