summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-11 10:50:03 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-05-11 10:50:03 +0200
commit70fd3f0ea563220211a5b412ebdab46eb0ce5ed4 (patch)
tree1c2f067cb92c270f2119d8ae27dfe127fb62efe1
parent73f8d93f0db5a960bf22e9d080283e967f6bbfb6 (diff)
Fix: wrong searchPath parameter
Change initialization parts of the function to be clearer and ensure that at least searchPath has been correctly passed Change-Id: Ic055e2c244b261b33960072f51193fcbbd48c222 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--filescan-utils.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index fbcdc64..70ca6ff 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -28,12 +28,17 @@
// List Avaliable Configuration Files
json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *prefix, const char *extention) {
- json_object *responseJ;
+ json_object *responseJ = json_object_new_array();
char *dirPath;
- char* dirList= strdup(searchPath);
+ char* dirList;
size_t extentionLen=0;
int count=0;
+ if(!searchPath)
+ return responseJ;
+
+ dirList = strdup(searchPath);
+
int ScanDir (char *searchPath) {
int found=0;
DIR *dirHandle;
@@ -79,8 +84,8 @@ json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const
return found;
}
- if (extention) extentionLen=strlen(extention);
- responseJ = json_object_new_array();
+ if (extention)
+ extentionLen=strlen(extention);
// loop recursively on dir
for (dirPath= strtok(dirList, ":"); dirPath && *dirPath; dirPath=strtok(NULL,":")) {
@@ -140,7 +145,7 @@ char *GetBindingDirPath(struct afb_dynapi *dynapi)
if(dynapi)
sprintf(fd_link, "/proc/self/fd/%d", afb_dynapi_rootdir_get_fd(dynapi));
else
- sprintf(fd_link, "/proc/self/fd/%d", afb_daemon_rootdir_get_fd_v2());
+ sprintf(fd_link, "/proc/self/fd/%d", afb_daemon_rootdir_get_fd());
if((len = readlink(fd_link, retdir, sizeof(retdir)-1)) == -1)
{