aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r--ctl-lib/ctl-plugin.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 2097afa..d20950f 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -112,10 +112,12 @@ static int PluginLoadCOne(AFB_ApiT apiHandle, const char *pluginpath, json_objec
int Lua2cAddOne(luaL_Reg *l2cFunc, const char* l2cName, int index) {
if(ctlPlugin->ctlL2cFunc->l2cCount)
{index += ctlPlugin->ctlL2cFunc->l2cCount+1;}
- char funcName[CONTROL_MAXPATH_LEN];
- funcName[CONTROL_MAXPATH_LEN - 1] = '\0';
- strncpy(funcName, "lua2c_", CONTROL_MAXPATH_LEN - 1);
- strncat(funcName, l2cName, CONTROL_MAXPATH_LEN - strlen (funcName) - 1);
+ char *funcName;
+ size_t p_length = 6 + strlen(l2cName);
+ funcName = malloc(p_length + 1);
+
+ strncpy(funcName, "lua2c_", p_length);
+ strncat(funcName, l2cName, p_length - strlen (funcName));
Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName);
if (!l2cFunction) {
@@ -213,13 +215,13 @@ static int LoadFoundPlugins(AFB_ApiT apiHandle, json_object *scanResult, json_ob
return -1;
}
- /* Make sure you don't load two found libraries */
ext = strrchr(filename, '.');
strncpy(pluginpath, fullpath, CONTROL_MAXPATH_LEN - 1);
strncat(pluginpath, "/", CONTROL_MAXPATH_LEN - strlen(pluginpath) - 1);
strncat(pluginpath, filename, CONTROL_MAXPATH_LEN - strlen (pluginpath) - 1);
if(!strcasecmp(ext, CTL_PLUGIN_EXT)) {
+ /* Make sure you don't load two found libraries */
if(ext && !strcasecmp(ext, CTL_PLUGIN_EXT) && i > 0) {
AFB_ApiWarning(apiHandle, "Plugin multiple instances in searchpath will use %s/%s", fullpath, filename);
return 0;