summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-03 15:42:26 +0100
committerRonan Le Martret <ronan.lemartret@iot.bzh>2017-11-24 10:38:06 +0100
commitaf19faae21bf209515dcb220a102b4adf7f5b7d5 (patch)
tree735dfc4b2dc21af14cf2f948ef8dfe37888dd899 /ctl-lib/ctl-plugin.c
parent19fd8c1f4b4d54d5dc2c4f586baed04e220142b1 (diff)
Fix: strncpy does't add null char at the end
Fix: handle null response from CtlScanConfig() Change-Id: Icbe2a649886998078adda35b0d0dfd1c46e8fe31 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r--ctl-lib/ctl-plugin.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 0df21ae..11df1e3 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -119,7 +119,7 @@ STATIC int PluginLoadOne (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object
}
char pluginpath[CONTROL_MAXPATH_LEN];
- strncpy(pluginpath, fullpath, strlen (fullpath));
+ strncpy(pluginpath, fullpath, strlen (fullpath)+1);
strncat(pluginpath, "/", strlen ("/"));
strncat(pluginpath, filename, strlen (filename));
dlHandle = dlopen(pluginpath, RTLD_NOW);
@@ -156,7 +156,7 @@ 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_", strlen ("lua2c_"));
+ strncpy(funcName, "lua2c_", strlen ("lua2c_")+1);
strncat(funcName, l2cName, strlen (l2cName));
Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName);