diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2024-01-23 09:22:00 +0100 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2024-02-08 09:27:54 +0100 |
commit | 42f538cc66546997a166dbe67e489c9afabbb908 (patch) | |
tree | 718bb6b7161892c4b964499c1818c6d7bf0bd6a6 /url.c | |
parent | 760031b4a74d70bdeaab4ce9aedfe772acd05bd3 (diff) |
download files
Diffstat (limited to 'url.c')
-rw-r--r-- | url.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -38,9 +38,9 @@ #include "url.h" bool -check_request_path(char *path) +check_request_path(char *path, char *suffix) { - char p [PATH_MAX], resolved[PATH_MAX]; + char p[PATH_MAX], resolved[PATH_MAX]; char *rp; /* build absolute path from DATA_DIR */ @@ -50,6 +50,13 @@ check_request_path(char *path) return false; if (strlcat(p, path, sizeof(p)) >= sizeof(p)) return false; + if (strlen(suffix) > 0) { + /* add suffix */ + if(strlcat(p, ".", sizeof(p)) >= sizeof(p)) + return false; + if(strlcat(p, suffix, sizeof(p)) >= sizeof(p)) + return false; + } /* canonicalize the path */ rp = realpath(p, resolved); |