From 9930e7cd82527aef90cbde2e5d8be2a4a27a2352 Mon Sep 17 00:00:00 2001 From: Stephan Leemburg Date: Wed, 7 Sep 2016 16:52:13 +0200 Subject: [PATCH 1/3] allow non-reverse mappings if reverseonly is not enabled --- src/reqs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/reqs.c b/src/reqs.c index d0f296f..86e1487 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -369,12 +369,15 @@ BAD_REQUEST_ERROR: reverse_url = reverse_rewrite_url (connptr, hashofheaders, url); - if (!reverse_url) { + if (!reverse_url && config.reverseonly) { goto fail; } - safefree (url); - url = reverse_url; + /* if not reverse only and a mapping was found.. */ + if(reverse_url) { + safefree (url); + url = reverse_url; + } } #endif From 0aedb9ba194cb0e91600e969782674dc65bc0a4a Mon Sep 17 00:00:00 2001 From: Stephan Leemburg Date: Wed, 7 Sep 2016 21:45:04 +0200 Subject: [PATCH 2/3] avoid null pointer dereference --- src/reverse-proxy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/reverse-proxy.c b/src/reverse-proxy.c index 9ca55f6..b2e2db1 100644 --- a/src/reverse-proxy.c +++ b/src/reverse-proxy.c @@ -166,7 +166,8 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders, return NULL; } - log_message (LOG_CONN, "Rewriting URL: %s -> %s", url, rewrite_url); + log_message (LOG_CONN, "Rewriting URL: %s -> %s", url, + rewrite_url ? rewrite_url : "No mapping found"); /* Store reverse path so that the magical tracking cookie can be set */ if (config.reversemagic && reverse) From 3b6e6d4b415f97a8d3213801d9ce1bda6469a294 Mon Sep 17 00:00:00 2001 From: Stephan Leemburg Date: Sat, 10 Sep 2016 18:10:32 +0200 Subject: [PATCH 3/3] allow non-reverse mappings if reverseonly is not enabled --- src/reqs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/reqs.c b/src/reqs.c index 86e1487..555c8c7 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -369,14 +369,14 @@ BAD_REQUEST_ERROR: reverse_url = reverse_rewrite_url (connptr, hashofheaders, url); - if (!reverse_url && config.reverseonly) { - goto fail; - } - - /* if not reverse only and a mapping was found.. */ - if(reverse_url) { + if (reverse_url != NULL) { safefree (url); url = reverse_url; + } else if (config.reverseonly) { + indicate_http_error (connptr, 400, "Bad Request", + "detail", "No mapping found for requested url", + "url", url, NULL); + goto fail; } } #endif