diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2024-12-26 17:25:35 +0100 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2024-12-26 17:25:35 +0100 |
commit | a29738212841dcb699dc397ad66c3416324eccf8 (patch) | |
tree | 3a28a9730f33461a34198c0c3ff50e7c73e04051 /download.c | |
parent | 69208140ddc9faa4e607cacefab6cae9badeaa7c (diff) |
remove check_request_path because we have unveil
Diffstat (limited to 'download.c')
-rw-r--r-- | download.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -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) { |