From 770cec2780c804cb65a8e6e4ded1d5ea4627c8f3 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 24 Jun 2019 16:03:55 -0700 Subject: [PATCH] ip: Fix get_link_kind when linked statically --- ip/iplink.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index edb88b02..76207e63 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -143,7 +143,6 @@ static int on_off(const char *msg, const char *realval) return -1; } -static void *BODY; /* cached dlopen(NULL) handle */ static struct link_util *linkutil_list; struct link_util *get_link_kind(const char *id) @@ -152,21 +151,98 @@ struct link_util *get_link_kind(const char *id) char buf[256]; struct link_util *l; + if (linkutil_list == NULL) { + // next) if (strcmp(l->id, id) == 0) return l; snprintf(buf, sizeof(buf), LIBDIR "/ip/link_%s.so", id); dlh = dlopen(buf, RTLD_LAZY); - if (dlh == NULL) { - /* look in current binary, only open once */ - dlh = BODY; - if (dlh == NULL) { - dlh = BODY = dlopen(NULL, RTLD_LAZY); - if (dlh == NULL) - return NULL; - } - } + if (dlh == NULL) + return NULL; snprintf(buf, sizeof(buf), "%s_link_util", id); l = dlsym(dlh, buf); -- 2.27.0