summaryrefslogtreecommitdiff
path: root/download.c
diff options
context:
space:
mode:
Diffstat (limited to 'download.c')
-rw-r--r--download.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/download.c b/download.c
index 02625fc..e80a51c 100644
--- a/download.c
+++ b/download.c
@@ -92,14 +92,6 @@ download(struct kreq * r)
KHTTP_200, ""
};
- /* 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) {
- KHTTP_400,
- "download: invalid request path"
- };
- goto end;
- }
/* build requested file path, with suffix or without */
if (strlen(r->suffix) > 0) {
if (snprintf(request_path, sizeof(request_path), "%s.%s", r->path, r->suffix)
@@ -129,6 +121,15 @@ download(struct kreq * r)
};
goto end;
}
+ /* we do not support downloading folders */
+ if (f->is_dir) {
+ ret = (struct http_ret) {
+ KHTTP_400,
+ "download: can't download folder"
+ };
+ goto end;
+ }
+ /* memory map the file */
path_size = file_get_data_path(f, file_path, PATH_MAX, NULL);
if (path_size == 0 || path_size >= PATH_MAX) {
ret = (struct http_ret) {
@@ -137,7 +138,6 @@ download(struct kreq * r)
};
goto end;
}
- /* memory map the file */
fd = open(file_path, O_RDONLY);
if (fd < 0) {
ret = (struct http_ret) {