From 186888ed39eb8a2e1cc531d180496d42eec04147 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 26 Oct 2019 05:31:01 +0100 Subject: [PATCH] ws proxy: ensure upgrade request url starts with slash In the case rpath is set to //, any urlargs will be added right at the start. Add a check to keep the initial / if so. https://github.com/warmcat/libwebsockets/issues/1733 --- lib/roles/http/server/server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index 132e962fe..57af8fe1b 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -1106,7 +1106,12 @@ lws_http_proxy_start(struct lws *wsi, const struct lws_http_mount *hit, lws_clean_url(rpath); na = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_URI_ARGS); if (na) { - char *p = rpath + n; + char *p; + + if (!n) /* don't start with the ?... use the first / if so */ + n++; + + p = rpath + n; if (na >= (int)sizeof(rpath) - n - 2) { lwsl_info("%s: query string %d longer "