ソースを参照

haproxy: fixes from upstream

 - [PATCH 14/16] BUG/MINOR: http: remove stupid HTTP_METH_NONE entry
 - [PATCH 15/16] BUG/MAJOR: http: don't call http_send_name_header()
 - [PATCH 16/16] BUG/MINOR: tools: make str2sa_range() report

Signed-off-by: heil <heil@terminal-consulting.de>
heil 9 年 前
コミット
1b9a79c04d

+ 1
- 1
net/haproxy/Makefile ファイルの表示

@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
10 10
 
11 11
 PKG_NAME:=haproxy
12 12
 PKG_VERSION:=1.5.14
13
-PKG_RELEASE:=13
13
+PKG_RELEASE:=16
14 14
 PKG_SOURCE:=haproxy-$(PKG_VERSION).tar.gz
15 15
 PKG_SOURCE_URL:=http://haproxy.1wt.eu/download/1.5/src/
16 16
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)

+ 78
- 0
net/haproxy/patches/0014-BUG-MINOR-http-remove-stupid-HTTP_METH_NONE-entry.patch ファイルの表示

@@ -0,0 +1,78 @@
1
+From bcd033699c5a4904967652de4980e4f35f17ee34 Mon Sep 17 00:00:00 2001
2
+From: Willy Tarreau <w@1wt.eu>
3
+Date: Thu, 3 Sep 2015 17:15:21 +0200
4
+Subject: [PATCH 14/16] BUG/MINOR: http: remove stupid HTTP_METH_NONE entry
5
+
6
+When converting the "method" fetch to a string, we used to get an empty
7
+string if the first character was not an upper case. This was caused by
8
+the lookup function which returns HTTP_METH_NONE when a lookup is not
9
+possible, and this method being mapped to an empty string in the array.
10
+
11
+This is a totally stupid mechanism, there's no reason for having the
12
+result depend on the first char. In fact the message parser already
13
+checks that the syntax matches an HTTP token so we can only land there
14
+with a valid token, hence only HTTP_METH_OTHER should be returned.
15
+
16
+This fix should be backported to all actively supported branches.
17
+(cherry picked from commit b7ce424be2bc9df73a3b971fa9dd6daea0332bf1)
18
+---
19
+ include/types/proto_http.h |  1 -
20
+ src/proto_http.c           | 11 ++++-------
21
+ 2 files changed, 4 insertions(+), 8 deletions(-)
22
+
23
+diff --git a/include/types/proto_http.h b/include/types/proto_http.h
24
+index a5a5d31..dbce972 100644
25
+--- a/include/types/proto_http.h
26
++++ b/include/types/proto_http.h
27
+@@ -219,7 +219,6 @@ enum {
28
+ 
29
+ /* Known HTTP methods */
30
+ enum http_meth_t {
31
+-	HTTP_METH_NONE = 0,
32
+ 	HTTP_METH_OPTIONS,
33
+ 	HTTP_METH_GET,
34
+ 	HTTP_METH_HEAD,
35
+diff --git a/src/proto_http.c b/src/proto_http.c
36
+index 02dc42b..46694cb 100644
37
+--- a/src/proto_http.c
38
++++ b/src/proto_http.c
39
+@@ -361,12 +361,11 @@ const struct http_method_desc http_methods[26][3] = {
40
+ 		[0] = {	.meth = HTTP_METH_TRACE   , .len=5, .text="TRACE"   },
41
+ 	},
42
+ 	/* rest is empty like this :
43
+-	 *      [1] = {	.meth = HTTP_METH_NONE    , .len=0, .text=""        },
44
++	 *      [0] = {	.meth = HTTP_METH_OTHER   , .len=0, .text=""        },
45
+ 	 */
46
+ };
47
+ 
48
+ const struct http_method_name http_known_methods[HTTP_METH_OTHER] = {
49
+-	[HTTP_METH_NONE]    = { "",         0 },
50
+ 	[HTTP_METH_OPTIONS] = { "OPTIONS",  7 },
51
+ 	[HTTP_METH_GET]     = { "GET",      3 },
52
+ 	[HTTP_METH_HEAD]    = { "HEAD",     4 },
53
+@@ -793,8 +792,8 @@ struct chunk *http_error_message(struct session *s, int msgnum)
54
+ }
55
+ 
56
+ /*
57
+- * returns HTTP_METH_NONE if there is nothing valid to read (empty or non-text
58
+- * string), HTTP_METH_OTHER for unknown methods, or the identified method.
59
++ * returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
60
++ * ones.
61
+  */
62
+ enum http_meth_t find_http_meth(const char *str, const int len)
63
+ {
64
+@@ -810,10 +809,8 @@ enum http_meth_t find_http_meth(const char *str, const int len)
65
+ 			if (likely(memcmp(str, h->text, h->len) == 0))
66
+ 				return h->meth;
67
+ 		};
68
+-		return HTTP_METH_OTHER;
69
+ 	}
70
+-	return HTTP_METH_NONE;
71
+-
72
++	return HTTP_METH_OTHER;
73
+ }
74
+ 
75
+ /* Parse the URI from the given transaction (which is assumed to be in request
76
+-- 
77
+2.4.6
78
+

+ 49
- 0
net/haproxy/patches/0015-BUG-MAJOR-http-don-t-call-http_send_name_header-afte.patch ファイルの表示

@@ -0,0 +1,49 @@
1
+From 3f34b5539e7ba31e44055d853b9ba496e73e0bae Mon Sep 17 00:00:00 2001
2
+From: Willy Tarreau <w@1wt.eu>
3
+Date: Mon, 7 Sep 2015 19:32:33 +0200
4
+Subject: [PATCH 15/16] BUG/MAJOR: http: don't call http_send_name_header()
5
+ after an error
6
+
7
+A crash was reported when using the "famous" http-send-name-header
8
+directive. This time it's a bit tricky, it requires a certain number of
9
+conditions to be met including maxconn on a server, queuing, timeout in
10
+the queue and cookie-based persistence.
11
+
12
+The problem is that in stream.c, before calling http_send_name_header(),
13
+we check a number of conditions to know if we have to replace the header
14
+name. But prior to reaching this place, it's possible for
15
+sess_update_stream_int() to fail and change the stream-int's state to
16
+SI_ST_CLO, send an error 503 to the client, and flush all buffers. But
17
+http_send_name_header() can only be called with valid buffer contents
18
+matching the http_msg's description. So when it rewinds the stream to
19
+modify the header, buf->o becomes negative by the size of the incoming
20
+request and is used as the argument to memmove() which basically
21
+displaces 4GB of memory off a few bytes to write the new name, resulting
22
+in a core and a core file that's really not fun to play with.
23
+
24
+The solution obviously consists in refraining from calling this nasty
25
+function when the stream interface is already closed.
26
+
27
+This bug also affects 1.5 and possibly 1.4, so the fix must be backported
28
+there.
29
+(cherry picked from commit 9c03b33329cb4924716edc1c851913a18b0670dc)
30
+---
31
+ src/session.c | 2 +-
32
+ 1 file changed, 1 insertion(+), 1 deletion(-)
33
+
34
+diff --git a/src/session.c b/src/session.c
35
+index 6d62e36..7520a85 100644
36
+--- a/src/session.c
37
++++ b/src/session.c
38
+@@ -2293,7 +2293,7 @@ struct task *process_session(struct task *t)
39
+ 
40
+ 			/* Now we can add the server name to a header (if requested) */
41
+ 			/* check for HTTP mode and proxy server_name_hdr_name != NULL */
42
+-			if ((s->si[1].state >= SI_ST_CON) &&
43
++			if ((s->si[1].state >= SI_ST_CON) && (s->si[1].state < SI_ST_CLO) &&
44
+ 			    (s->be->server_id_hdr_name != NULL) &&
45
+ 			    (s->be->mode == PR_MODE_HTTP) &&
46
+ 			    objt_server(s->target)) {
47
+-- 
48
+2.4.6
49
+

+ 36
- 0
net/haproxy/patches/0016-BUG-MINOR-tools-make-str2sa_range-report-unresolvabl.patch ファイルの表示

@@ -0,0 +1,36 @@
1
+From 36456071ea34546d98d3b66a696cd4c4c4643de5 Mon Sep 17 00:00:00 2001
2
+From: Willy Tarreau <w@1wt.eu>
3
+Date: Tue, 8 Sep 2015 16:01:25 +0200
4
+Subject: [PATCH 16/16] BUG/MINOR: tools: make str2sa_range() report
5
+ unresolvable addresses
6
+
7
+If an environment variable is used in an address, and is not set, it's
8
+silently considered as ":" or "0.0.0.0:0" which is not correct as it
9
+can hide environment issues and lead to unexpected behaviours. Let's
10
+report this case when it happens.
11
+
12
+This fix should be backported to 1.5.
13
+(cherry picked from commit 9f69f46d1f1b1d116c00b4b0483c519747f977b7)
14
+---
15
+ src/standard.c | 5 +++++
16
+ 1 file changed, 5 insertions(+)
17
+
18
+diff --git a/src/standard.c b/src/standard.c
19
+index f57724c..9299882 100644
20
+--- a/src/standard.c
21
++++ b/src/standard.c
22
+@@ -709,6 +709,11 @@ struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high, char
23
+ 		goto out;
24
+ 	}
25
+ 
26
++	if (!*str2) {
27
++		memprintf(err, "'%s' resolves to an empty address (environment variable missing?)\n", str);
28
++		goto out;
29
++	}
30
++
31
+ 	memset(&ss, 0, sizeof(ss));
32
+ 
33
+ 	if (strncmp(str2, "unix@", 5) == 0) {
34
+-- 
35
+2.4.6
36
+