summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2021-03-28 20:36:55 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2021-03-28 20:36:55 +0100
commit11a4f6c5cfc078d037930b2618b9bc8bb0550493 (patch)
tree513394f68d19930d9189ec99890928fb07748f05
parent64badd6b373b243e6f431c8adcff92e58925a8b9 (diff)
reverse: ensure paths always end with a slash
-rw-r--r--src/reverse-proxy.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/reverse-proxy.c b/src/reverse-proxy.c
index af58d56..4008120 100644
--- a/src/reverse-proxy.c
+++ b/src/reverse-proxy.c
@@ -34,6 +34,7 @@ void reversepath_add (const char *path, const char *url,
struct reversepath **reversepath_list)
{
struct reversepath *reverse;
+ size_t l;
if (url == NULL) {
log_message (LOG_WARNING,
@@ -65,8 +66,17 @@ void reversepath_add (const char *path, const char *url,
if (!path)
reverse->path = safestrdup ("/");
- else
- reverse->path = safestrdup (path);
+ else {
+ l = strlen (path);
+ if (l && path[l-1] == '/')
+ reverse->path = safestrdup (path);
+ else {
+ reverse->path = safemalloc (l + 2);
+ memcpy (reverse->path, path, l);
+ reverse->path[l] = '/';
+ reverse->path[l+1] = 0;
+ }
+ }
reverse->url = safestrdup (url);