summaryrefslogtreecommitdiff
path: root/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'url.c')
-rw-r--r--url.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/url.c b/url.c
index 228efeb..3e82821 100644
--- a/url.c
+++ b/url.c
@@ -41,10 +41,14 @@ bool
check_request_path(char *path, char *suffix)
{
char p[PATH_MAX], resolved[PATH_MAX];
- char *rp;
+ char *rp, *data_dir;
+
+ data_dir = config_data_dir();
+ if (data_dir == NULL)
+ return false;
/* build absolute path from DATA_DIR */
- if (strlcpy(p, DATA_DIR, sizeof(p)) >= sizeof(p))
+ if (strlcpy(p, data_dir, sizeof(p)) >= sizeof(p))
return false;
if (strlcat(p, "/", sizeof(p)) >= sizeof(p))
return false;
@@ -52,9 +56,9 @@ check_request_path(char *path, char *suffix)
return false;
if (strlen(suffix) > 0) {
/* add suffix */
- if(strlcat(p, ".", sizeof(p)) >= sizeof(p))
+ if (strlcat(p, ".", sizeof(p)) >= sizeof(p))
return false;
- if(strlcat(p, suffix, sizeof(p)) >= sizeof(p))
+ if (strlcat(p, suffix, sizeof(p)) >= sizeof(p))
return false;
}
@@ -65,7 +69,7 @@ check_request_path(char *path, char *suffix)
/* path must start with DATA_DIR */
rp[PATH_MAX - 1] = '\0';
- if (strstr(rp, DATA_DIR) != rp)
+ if (strstr(rp, data_dir) != rp)
return false;
return true;
@@ -92,7 +96,7 @@ url_build(char *dst, size_t dst_size,...)
if (path[0] == '.' && path[1] == '\0')
continue;
- if (path[0] != '/' && dst[w_size - 1] != '/')
+ if (path[0] != '/' && w_size > 0 && dst[w_size - 1] != '/')
strlcat(dst, "/", dst_size);
w_size = strlcat(dst, path, dst_size);