summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-02 14:54:25 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:54 +0100
commit723b3c8d8d9e75ff7c1b6573cc5edd718fc05ac2 (patch)
treeb861a9958459d809b13472ace1a5612e58a23805 /ctl-lib/ctl-plugin.c
parent5ea27091ffd08d0c9cb9368d274bd0998fd89a77 (diff)
fix: wrong usage of strncat and strncpy function
3rd arguments match strlen of 2nd arguments and should not match the maximum length of destination variable. Change-Id: Ifebf6097bb995d0cf2c5633eb94d52d4517ade7b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r--ctl-lib/ctl-plugin.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 4d9414f..1304984 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -119,9 +119,9 @@ STATIC int PluginLoadOne (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object
}
char pluginpath[CONTROL_MAXPATH_LEN];
- strncpy(pluginpath, fullpath, sizeof (pluginpath));
- strncat(pluginpath, "/", sizeof (pluginpath));
- strncat(pluginpath, filename, sizeof (pluginpath));
+ strncpy(pluginpath, fullpath, strlen (fullpath));
+ strncat(pluginpath, "/", strlen ("/"));
+ strncat(pluginpath, filename, strlen (filename));
dlHandle = dlopen(pluginpath, RTLD_NOW);
if (!dlHandle) {
AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Fail to load pluginpath=%s err= %s", pluginpath, dlerror());
@@ -156,8 +156,8 @@ STATIC int PluginLoadOne (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object
int Lua2cAddOne(luaL_Reg *l2cFunc, const char* l2cName, int index) {
char funcName[CONTROL_MAXPATH_LEN];
- strncpy(funcName, "lua2c_", sizeof (funcName));
- strncat(funcName, l2cName, sizeof (funcName));
+ strncpy(funcName, "lua2c_", strlen ("lua2c_"));
+ strncat(funcName, l2cName, strlen (l2cName));
Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName);
if (!l2cFunction) {