From af19faae21bf209515dcb220a102b4adf7f5b7d5 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 3 Nov 2017 15:42:26 +0100 Subject: Fix: strncpy does't add null char at the end Fix: handle null response from CtlScanConfig() Change-Id: Icbe2a649886998078adda35b0d0dfd1c46e8fe31 Signed-off-by: Romain Forlot --- ctl-lib/ctl-plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ctl-lib/ctl-plugin.c') 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); -- cgit 1.2.3-korg