From 6cf3b3c0dcdf27840fe1994632e1ee8d021d1468 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Wed, 11 Jul 2018 11:08:44 +0200 Subject: [PATCH] Only use kore_root_path if its explicitly set. Otherwise a relative path works well enough. --- src/filemap.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/filemap.c b/src/filemap.c index ea95779..1dce34a 100644 --- 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);