aboutsummaryrefslogtreecommitdiffstats
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)
{
>197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308