summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filescan-utils.c31
-rw-r--r--filescan-utils.h11
2 files changed, 6 insertions, 36 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index fe01bdc..83565b2 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -126,42 +126,21 @@ PUBLIC const char *GetBinderName() {
PUBLIC const char *GetBindingDirPath(BindingDirsT dir)
{
// A file description should not be greater than 999.999.999
- char fd[10];
- static char retdir[CONTROL_MAXPATH_LEN];
- sprintf(fd, "%d", afb_daemon_rootdir_get_fd());
- char* fd_link = malloc(strlen("/proc/self/fd/") + strlen(fd));
- strcpy(fd_link, "/proc/self/fd/");
- strcat(fd_link, fd);
+ char fd_link[CONTROL_MAXPATH_LEN];
+ char retdir[CONTROL_MAXPATH_LEN];
+ sprintf(fd_link, "/proc/self/fd/%d", afb_daemon_rootdir_get_fd());
ssize_t len;
if((len = readlink(fd_link, retdir, sizeof(retdir)-1)) == -1)
{
perror("lstat");
AFB_ERROR("Error reading stat of link: %s", fd_link);
- strcpy(retdir, "/tmp");
+ strncpy(retdir, "/tmp", 4);
}
else
{
retdir[len] = '\0';
- switch (dir) {
- case BIN_DIR:
- strcat(retdir, "/bin");
- break;
- case ETC_DIR:
- strcat(retdir, "/etc");
- break;
- case LIB_DIR:
- strcat(retdir, "/lib");
- break;
- case DATA_DIR:
- strcat(retdir, "/data");
- break;
- case HTTP_DIR:
- strcat(retdir, "/http");
- break;
- }
}
- free(fd_link);
- return retdir;
+ return strndup(retdir, sizeof(retdir));
}
diff --git a/filescan-utils.h b/filescan-utils.h
index 738be27..68df0fc 100644
--- a/filescan-utils.h
+++ b/filescan-utils.h
@@ -44,19 +44,10 @@ typedef enum {
CTL_SCAN_RECURSIVE=1,
} CtlScanDirModeT;
-typedef enum {
- ROOT_DIR=0,
- BIN_DIR=1,
- ETC_DIR=2,
- DATA_DIR=3,
- LIB_DIR=4,
- HTTP_DIR=5
-} BindingDirsT
-
PUBLIC const char *GetMidleName(const char*name);
PUBLIC const char *GetBinderName();
PUBLIC json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *pre, const char *ext);
-PUBLIC const char *GetBindingDirPath(BindingDirsT dir);
+PUBLIC const char *GetBindingDirPath();
#ifdef __cplusplus