summaryrefslogtreecommitdiffstats
path: root/controller/ctl-lua.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-26 18:38:57 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit0ea61ebe60b1be3b33c400bf1a8ebf9cc6644349 (patch)
tree48645f3073c2bdc2a18de2a1d2c9ff4123302ea6 /controller/ctl-lua.c
parent6b492d666ed1faeeec5f761105f473956b426cc9 (diff)
Better use of strncat
Change-Id: I89a1ab96280f7502b0e2f21adc30652b96f82932 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller/ctl-lua.c')
-rw-r--r--controller/ctl-lua.c10
1 files changed, 5 insertions, 5 deletions
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));