summaryrefslogtreecommitdiffstats
path: root/filescan-utils.c
diff options
context:
space:
mode:
authorRonan Le Martret <ronan.lemartret@iot.bzh>2017-08-29 16:09:07 +0200
committerRonan Le Martret <ronan.lemartret@iot.bzh>2017-08-29 16:10:29 +0200
commit55f0a986d2c819731e45e5612dfc76a5d1ca76ce (patch)
tree83fe166f7c87bdfa604f5370b2886008eb3d3d1a /filescan-utils.c
parent9db0b6603a4144b35615943031b4ca31c8c2b63f (diff)
fix strncat funct
I: Statement might be overflowing a buffer in strncat. Common mistake: BAD: strncat(buffer,charptr,sizeof(buffer)) is wrong, it takes the left over size as 3rd argument GOOD: strncat(buffer,charptr,sizeof(buffer)-strlen(buffer)-1) Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
Diffstat (limited to 'filescan-utils.c')
-rw-r--r--filescan-utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index e735682..f1de9d0 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -49,8 +49,8 @@ PUBLIC json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode,
if (dirEnt->d_name[0]=='.' || dirEnt->d_name[0]=='_') continue;
strncpy(newpath, searchPath, sizeof(newpath));
- strncat(newpath, "/", sizeof(newpath));
- strncat(newpath, dirEnt->d_name, sizeof(newpath));
+ strncat(newpath, "/", sizeof(newpath)-strlen(newpath)-1);
+ strncat(newpath, dirEnt->d_name, sizeof(newpath)-strlen(newpath)-1);
ScanDir(newpath);
continue;
}