diff options
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r-- | ctl-lib/ctl-plugin.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c index 0029b68..2097afa 100644 --- a/ctl-lib/ctl-plugin.c +++ b/ctl-lib/ctl-plugin.c @@ -113,8 +113,9 @@ static int PluginLoadCOne(AFB_ApiT apiHandle, const char *pluginpath, json_objec if(ctlPlugin->ctlL2cFunc->l2cCount) {index += ctlPlugin->ctlL2cFunc->l2cCount+1;} char funcName[CONTROL_MAXPATH_LEN]; - strncpy(funcName, "lua2c_", strlen ("lua2c_")+1); - strncat(funcName, l2cName, strlen (l2cName)); + funcName[CONTROL_MAXPATH_LEN - 1] = '\0'; + strncpy(funcName, "lua2c_", CONTROL_MAXPATH_LEN - 1); + strncat(funcName, l2cName, CONTROL_MAXPATH_LEN - strlen (funcName) - 1); Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName); if (!l2cFunction) { @@ -194,6 +195,8 @@ static int LoadFoundPlugins(AFB_ApiT apiHandle, json_object *scanResult, json_ob size_t len; json_object *object = NULL; + pluginpath[CONTROL_MAXPATH_LEN - 1] = '\0'; + if (!json_object_is_type(scanResult, json_type_array)) return -1; @@ -212,9 +215,9 @@ static int LoadFoundPlugins(AFB_ApiT apiHandle, json_object *scanResult, json_ob /* Make sure you don't load two found libraries */ ext = strrchr(filename, '.'); - strncpy(pluginpath, fullpath, strlen (fullpath)+1); - strncat(pluginpath, "/", strlen ("/")); - strncat(pluginpath, filename, strlen (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)) { if(ext && !strcasecmp(ext, CTL_PLUGIN_EXT) && i > 0) { @@ -259,7 +262,7 @@ static char *GetDefaultSearchPath(AFB_ApiT apiHandle) strncat(searchPath, CONTROL_PLUGIN_PATH, CTL_PLGN_len); } - strncat(searchPath, ":", 1); + strncat(searchPath, ":", sizeof(searchPath) - 1); strncat(searchPath, bindingPath, bindingPath_len); return searchPath; |