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
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:54 +0100
commit25b02ddcd940fbf2f19d0012309d7945c389861c (patch)
tree735dfc4b2dc21af14cf2f948ef8dfe37888dd899 /ctl-lib/ctl-plugin.c
parent644db20dec0db50c857e5420ba731528dfff87e1 (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);