diff options
Diffstat (limited to 'browse.c')
-rw-r--r-- | browse.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -208,6 +208,7 @@ browse(struct kreq * r) { size_t url_len; char current_dir[PATH_MAX]; + char *data_dir; struct file *file; struct page_template *tmpl; struct http_ret ret; @@ -223,6 +224,16 @@ browse(struct kreq * r) KHTTP_200, "" }; + /* check that data dir is configured */ + data_dir = config_data_dir(); + if (data_dir == NULL) { + ret = (struct http_ret) { + KHTTP_400, + "browse: data dir is not configured" + }; + goto end; + } + /* check that the requested URL can be safely processed */ if (!check_request_path(r->path, r->suffix)) { ret = (struct http_ret) { @@ -232,7 +243,7 @@ browse(struct kreq * r) goto end; } /* list requested directory content */ - url_len = url_build(current_dir, PATH_MAX, DATA_DIR, r->path, + url_len = url_build(current_dir, PATH_MAX, data_dir, r->path, NULL); if (url_len == 0) { ret = (struct http_ret) { |