diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-05-11 10:50:03 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-13 14:12:02 +0100 |
commit | 6f69f0b9a69e43653a7b127677e2e16ef7756998 (patch) | |
tree | 1c2f067cb92c270f2119d8ae27dfe127fb62efe1 | |
parent | 3ac370d79120d166859c04bb2d5ab043bdba4c0a (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.c | 15 |
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) { |