commit 6cf3b3c0dcdf27840fe1994632e1ee8d021d1468
parent 207faad3c2681d30528b157b728b78dc8d5c03b9
Author: Joris Vink <joris@coders.se>
Date: Wed, 11 Jul 2018 11:08:44 +0200
Only use kore_root_path if its explicitly set.
Otherwise a relative path works well enough.
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/filemap.c b/src/filemap.c
@@ -68,9 +68,15 @@ kore_filemap_create(struct kore_domain *dom, const char *path, const char *root)
if (root[0] != '/' || root[sz - 1] != '/')
return (KORE_RESULT_ERROR);
- len = snprintf(fpath, sizeof(fpath), "%s/%s", kore_root_path, path);
- if (len == -1 || (size_t)len >= sizeof(regex))
- fatal("kore_filemap_create: failed to concat paths");
+ if (kore_root_path != NULL) {
+ len = snprintf(fpath, sizeof(fpath), "%s/%s",
+ kore_root_path, path);
+ if (len == -1 || (size_t)len >= sizeof(fpath))
+ fatal("kore_filemap_create: failed to concat paths");
+ } else {
+ if (kore_strlcpy(fpath, path, sizeof(fpath)) >= sizeof(fpath))
+ fatal("kore_filemap_create: failed to copy path");
+ }
if (stat(fpath, &st) == -1)
return (KORE_RESULT_ERROR);