diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-26 18:38:57 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | 0ea61ebe60b1be3b33c400bf1a8ebf9cc6644349 (patch) | |
tree | 48645f3073c2bdc2a18de2a1d2c9ff4123302ea6 /controller | |
parent | 6b492d666ed1faeeec5f761105f473956b426cc9 (diff) |
Better use of strncat
Change-Id: I89a1ab96280f7502b0e2f21adc30652b96f82932
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller')
-rw-r--r-- | controller/ctl-config.c | 4 | ||||
-rw-r--r-- | controller/ctl-lua.c | 10 | ||||
-rw-r--r-- | controller/ctl-plugin.c | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/controller/ctl-config.c b/controller/ctl-config.c index 580c68c..fe76c90 100644 --- a/controller/ctl-config.c +++ b/controller/ctl-config.c @@ -57,8 +57,8 @@ char* CtlConfigSearch(const char *dirList, const char* fileName) { if (strcasestr(filename, controlFile)) { char filepath[CONTROL_MAXPATH_LEN]; strncpy(filepath, fullpath, sizeof (filepath)); - strncat(filepath, "/", sizeof (filepath)); - strncat(filepath, filename, sizeof (filepath)); + strncat(filepath, "/", strlen("/")); + strncat(filepath, filename, strlen(filename)); return (strdup(filepath)); } } diff --git a/controller/ctl-lua.c b/controller/ctl-lua.c index f694e58..76faed6 100644 --- a/controller/ctl-lua.c +++ b/controller/ctl-lua.c @@ -740,8 +740,8 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) { if (!luaScriptPathJ) { const char* dirList = strncat(GetBindingDirPath(), "/data", sizeof(GetBindingDirPath()) - strlen(GetBindingDirPath()) - 1); strncpy(luaScriptPath,CONTROL_DOSCRIPT_PRE, sizeof(luaScriptPath)); - strncat(luaScriptPath,"-", sizeof(luaScriptPath)); - strncat(luaScriptPath,target, sizeof(luaScriptPath)); + strncat(luaScriptPath,"-", strlen("-")); + strncat(luaScriptPath,target, strlen(target)); luaScriptPathJ= ScanForConfig(dirList, CTL_SCAN_RECURSIVE,luaScriptPath,".lua"); } for (index=0; index < json_object_array_length(luaScriptPathJ); index++) { @@ -757,7 +757,7 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) { else { strncpy (luaScriptPath, fullpath, sizeof(luaScriptPath)); strncat (luaScriptPath, "/", sizeof(luaScriptPath)); - strncat (luaScriptPath, filename, sizeof(luaScriptPath)); + strncat (luaScriptPath, filename, strlen(filename)); } } @@ -777,7 +777,7 @@ STATIC void LuaDoAction (LuaDoActionT action, afb_req request) { // if no func name given try to deduct from filename if (!func && (func=(char*)GetMidleName(filename))!=NULL) { strncpy(luaScriptPath,"_", sizeof(luaScriptPath)); - strncat(luaScriptPath,func, sizeof(luaScriptPath)); + strncat(luaScriptPath,func, strlen(func)); func=luaScriptPath; } if (!func) { @@ -1052,7 +1052,7 @@ int LuaConfigExec () { char filepath[CONTROL_MAXPATH_LEN]; strncpy(filepath, fullpath, sizeof(filepath)); strncat(filepath, "/", sizeof(filepath)); - strncat(filepath, filename, sizeof(filepath)); + strncat(filepath, filename, strlen(filename)); err= luaL_loadfile(luaState, filepath); if (err) { AFB_ERROR ("LUA-LOAD HOOPs Error in LUA loading scripts=%s err=%s", filepath, lua_tostring(luaState,-1)); diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c index 9e4e419..6c73573 100644 --- a/controller/ctl-plugin.c +++ b/controller/ctl-plugin.c @@ -159,10 +159,10 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han 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)); + strncat(funcName, l2cName, strlen(l2cName)); Lua2cFunctionT l2cFunction = (Lua2cFunctionT) dlsym(dlHandle, funcName); - if (!l2cFunction) { + if (!l2cFunction) { AFB_ERROR("CTL-PLUGIN-LOADONE symbol'%s' missing err=%s", funcName, dlerror()); return 1; } |