1
commit 1c90a6ec20946a713e9c93995a8e91ed3eeb9da4
2
Author: Willy Tarreau <w@1wt.eu>
3
Date: Sun Oct 12 17:26:37 2008 +0200
5
[BUG] acl-related keywords are not allowed in defaults sections
7
Using an ACL-related keyword in the defaults section causes a
8
segfault during parsing because the list headers are not initialized.
9
We must initialize list headers for default instance and reject
10
keywords relying on ACLs.
12
diff --git a/src/cfgparse.c b/src/cfgparse.c
13
index b33800c..038915a 100644
16
@@ -516,6 +516,13 @@ static void init_default_instance()
17
defproxy.maxconn = cfg_maxpconn;
18
defproxy.conn_retries = CONN_RETRIES;
19
defproxy.logfac1 = defproxy.logfac2 = -1; /* log disabled */
21
+ LIST_INIT(&defproxy.pendconns);
22
+ LIST_INIT(&defproxy.acl);
23
+ LIST_INIT(&defproxy.block_cond);
24
+ LIST_INIT(&defproxy.mon_fail_cond);
25
+ LIST_INIT(&defproxy.switching_rules);
27
proxy_reset_timeouts(&defproxy);
30
@@ -837,6 +844,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
31
curproxy->state = PR_STNEW;
33
else if (!strcmp(args[0], "acl")) { /* add an ACL */
34
+ if (curproxy == &defproxy) {
35
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
39
err = invalid_char(args[1]);
41
Alert("parsing [%s:%d] : character '%c' is not permitted in acl name '%s'.\n",
42
@@ -1076,6 +1088,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
43
int pol = ACL_COND_NONE;
44
struct acl_cond *cond;
46
+ if (curproxy == &defproxy) {
47
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
51
if (!strcmp(args[1], "if"))
53
else if (!strcmp(args[1], "unless"))
54
@@ -1099,6 +1116,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
55
struct acl_cond *cond;
56
struct switching_rule *rule;
58
+ if (curproxy == &defproxy) {
59
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
63
if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL))
66
@@ -1376,6 +1398,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
69
else if (!strcmp(args[0], "monitor")) {
70
+ if (curproxy == &defproxy) {
71
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
75
if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL))