Merge pull request #8518 from neheb/i
[feed/packages.git] / net / haproxy / patches / 004-BUG-MEDIUM-contrib-modsecurity-If-host-header-is-NULL-dont-try-to-strdup-it.patch
1 commit 95cf225d099dcb49eefcf4f5b648be604414ae0c
2 Author: Yann Cézard <ycezard@viareport.com>
3 Date: Thu Apr 25 14:30:23 2019 +0200
4
5 BUG/MEDIUM: contrib/modsecurity: If host header is NULL, don't try to strdup it
6
7 I discovered this bug when running OWASP regression tests against HAProxy +
8 modsecurity-spoa (it's a POC to evaluate how it is working). I found out that
9 modsecurity spoa will crash when the request doesn't have any Host header.
10
11 See the pull request #86 on github for details.
12
13 This patch must be backported to 1.9 and 1.8.
14
15 (cherry picked from commit bf60f6b8033deddc86de5357d6099c7593fe44cc)
16 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
17 (cherry picked from commit d988e3dddcbe1f48f3b24d1bb529fc9ecefde180)
18 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
19
20 diff --git a/contrib/modsecurity/modsec_wrapper.c b/contrib/modsecurity/modsec_wrapper.c
21 index 271ec15d..2f3987b4 100644
22 --- a/contrib/modsecurity/modsec_wrapper.c
23 +++ b/contrib/modsecurity/modsec_wrapper.c
24 @@ -325,7 +325,11 @@ int modsecurity_process(struct worker *worker, struct modsecurity_parameters *pa
25 req->content_type = apr_table_get(req->headers_in, "Content-Type");
26 req->content_encoding = apr_table_get(req->headers_in, "Content-Encoding");
27 req->hostname = apr_table_get(req->headers_in, "Host");
28 - req->parsed_uri.hostname = chunk_strdup(req, req->hostname, strlen(req->hostname));
29 + if (req->hostname != NULL) {
30 + req->parsed_uri.hostname = chunk_strdup(req, req->hostname, strlen(req->hostname));
31 + } else {
32 + req->parsed_uri.hostname = NULL;
33 + }
34
35 lang = apr_table_get(req->headers_in, "Content-Languages");
36 if (lang != NULL) {