From 0ea61ebe60b1be3b33c400bf1a8ebf9cc6644349 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 26 Sep 2017 18:38:57 +0200 Subject: Better use of strncat Change-Id: I89a1ab96280f7502b0e2f21adc30652b96f82932 Signed-off-by: Romain Forlot --- controller/ctl-lua.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'controller/ctl-lua.c') 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)); -- cgit 1.2.3-korg