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 c2289471b14f956f3858837eda89a83e684d56af
parent 616af063e3a83d94d46e75fe33730a6e4025626b
Author: Joris Vink <joris@coders.se>
Date:   Tue, 17 Jul 2018 15:05:20 +0200

forcefully limit filemaps to GET | HEAD.

Diffstat:
src/filemap.c | 23+++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/filemap.c b/src/filemap.c @@ -55,11 +55,12 @@ kore_filemap_init(void) int kore_filemap_create(struct kore_domain *dom, const char *path, const char *root) { - size_t sz; - struct stat st; - int len; - struct filemap_entry *entry; - char regex[1024], fpath[PATH_MAX]; + size_t sz; + struct stat st; + int len; + struct kore_module_handle *hdlr; + struct filemap_entry *entry; + char regex[1024], fpath[PATH_MAX]; sz = strlen(root); if (sz == 0) @@ -89,8 +90,18 @@ kore_filemap_create(struct kore_domain *dom, const char *path, const char *root) "filemap_resolve", NULL, HANDLER_TYPE_DYNAMIC)) return (KORE_RESULT_ERROR); - entry = kore_calloc(1, sizeof(*entry)); + hdlr = NULL; + TAILQ_FOREACH(hdlr, &dom->handlers, list) { + if (!strcmp(hdlr->path, regex)) + break; + } + if (hdlr == NULL) + fatal("couldn't find newly created handler for filemap"); + + hdlr->methods = HTTP_METHOD_GET | HTTP_METHOD_HEAD; + + entry = kore_calloc(1, sizeof(*entry)); entry->domain = dom; entry->root_len = sz; entry->root = kore_strdup(root);