summaryrefslogtreecommitdiff
path: root/download.c
diff options
context:
space:
mode:
Diffstat (limited to 'download.c')
-rw-r--r--download.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/download.c b/download.c
index bff1dd6..a8f5947 100644
--- a/download.c
+++ b/download.c
@@ -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) {