kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 04deeeafb993bc8652eebcbdcfd76d5a06081858
parent 5eb2160269e4ba620417df0213363303161ac9fa
Author: Joris Vink <joris@coders.se>
Date:   Sun,  8 Jul 2018 15:57:00 +0000

make sure we can still resolve new paths

Diffstat:
src/filemap.c | 26++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/filemap.c b/src/filemap.c @@ -177,8 +177,30 @@ filemap_serve(struct http_request *req, struct filemap_entry *map) index = 0; lookup: - if (realpath(fpath, rpath) == NULL || - strncmp(rpath, fpath, map->ondisk_len)) { + if (realpath(fpath, rpath) == NULL) { + if (errno == ENOENT) { + if (index || kore_filemap_ext == NULL) { + req->status = HTTP_STATUS_NOT_FOUND; + } else { + len = snprintf(fpath, sizeof(fpath), + "%s/%s%s", map->ondisk, path, + kore_filemap_ext); + if (len == -1 || + (size_t)len >= sizeof(fpath)) { + http_response(req, + HTTP_STATUS_INTERNAL_ERROR, + NULL, 0); + return; + } + index++; + goto lookup; + } + } + http_response(req, HTTP_STATUS_NOT_FOUND, NULL, 0); + return; + } + + if (strncmp(rpath, fpath, map->ondisk_len)) { http_response(req, HTTP_STATUS_NOT_FOUND, NULL, 0); return; }