summaryrefslogtreecommitdiff
path: root/src/plugin.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2022-12-05 17:10:45 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2022-12-05 17:10:45 -0500
commit3bc7866f34ba9b16c8c15484c9e0ba53080124c0 (patch)
tree8435c6f8ca0e4db914ee19a7e3bce910fbc83af8 /src/plugin.c
parentf49b2d746781a75a652d1e6a0365a20c75ffb185 (diff)
downloadlighttpd-git-3bc7866f34ba9b16c8c15484c9e0ba53080124c0.tar.gz
[core] check for built-in plugins before dlopen
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 8a790117..436d546c 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -180,6 +180,18 @@ int plugins_load(server *srv) {
const buffer * const module = &((data_string *)srv->srvconf.modules->data[i])->value;
void *lib = NULL;
+ /* check if module is built-in to main executable */
+ buffer_clear(tb);
+ buffer_append_str2(tb, BUF_PTR_LEN(module),
+ CONST_STR_LEN("_plugin_init"));
+ #ifdef _WIN32
+ init = (int(WINAPI *)(plugin *))(intptr_t)
+ GetProcAddress(GetModuleHandle(NULL), tb->ptr);
+ #else
+ init = (int (*)(plugin *))(intptr_t)dlsym(RTLD_DEFAULT, tb->ptr);
+ #endif
+
+ if (NULL == init) {
buffer_copy_string(tb, srv->srvconf.modules_dir);
buffer_append_path_len(tb, BUF_PTR_LEN(module));
@@ -233,6 +245,7 @@ int plugins_load(server *srv) {
return -1;
}
#endif
+ }
plugin *p = plugin_init();
p->lib = lib;