diff options
Diffstat (limited to 'download.c')
-rw-r--r-- | download.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -79,7 +79,7 @@ build_download_url(struct kreq * r, struct file * file) struct http_ret download(struct kreq * r) { - char *file_name; + char *file_name, *data_dir; void *buffer; struct file *f; int fd; @@ -93,6 +93,16 @@ download(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, + "download: data dir not configured" + }; + goto end; + } + /* check that the requested URL can be safely processed */ if (strlen(r->path) == 0 || !check_request_path(r->path, r->suffix)) { ret = (struct http_ret) { @@ -122,7 +132,7 @@ download(struct kreq * r) } } - path_size = url_build(file_path, PATH_MAX, DATA_DIR, request_path, + path_size = url_build(file_path, PATH_MAX, data_dir, request_path, NULL); if (path_size == 0) { ret = (struct http_ret) { |