diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2022-12-05 17:10:45 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2022-12-05 17:10:45 -0500 |
commit | 3bc7866f34ba9b16c8c15484c9e0ba53080124c0 (patch) | |
tree | 8435c6f8ca0e4db914ee19a7e3bce910fbc83af8 /src/plugin.c | |
parent | f49b2d746781a75a652d1e6a0365a20c75ffb185 (diff) | |
download | lighttpd-git-3bc7866f34ba9b16c8c15484c9e0ba53080124c0.tar.gz |
[core] check for built-in plugins before dlopen
Diffstat (limited to 'src/plugin.c')
-rw-r--r-- | src/plugin.c | 13 |
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; |