packages/net/haproxy/patches/0001-BUG-MINOR-config-use-a-copy-of-the-file-name-i-1.4.22.diff
heil 240ad98e89 package: haproxy
- add missing patches
 - add patch number to version



git-svn-id: svn://svn.openwrt.org/openwrt/packages@35091 3c298f89-4303-0410-b956-a3cf2f4a3e73
2013-01-10 23:47:03 +00:00

76 lines
2.6 KiB
Diff

From 60f05a8eae1afda44d62066445a0c072659a1aa1 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Thu, 4 Oct 2012 08:01:43 +0200
Subject: BUG/MINOR: config: use a copy of the file name in proxy configurations
Each proxy contains a reference to the original config file and line
number where it was declared. The pointer used is just a reference to
the one passed to the function instead of being duplicated. The effect
is that it is not valid anymore at the end of the parsing and that all
proxies will be enumerated as coming from the same file on some late
configuration errors. This may happen for exmaple when reporting SSL
certificate issues.
By copying using strdup(), we avoid this issue.
1.4 has the same issue, though no report of the proxy file name is done
out of the config section. Anyway a backport is recommended to ease
post-mortem analysis.
(cherry picked from commit 8113a5d78f2d2abe942f88a3a4df9f8bb5e535ba)
---
include/types/proxy.h | 2 +-
src/cfgparse.c | 4 ++--
src/haproxy.c | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 1773658..a06078a 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -320,7 +320,7 @@ struct proxy {
int no_options2; /* PR_O2_* */
struct {
- const char *file; /* file where the section appears */
+ char *file; /* file where the section appears */
int line; /* line where the section appears */
struct eb32_node id; /* place in the tree of used IDs */
struct eb_root used_listener_id;/* list of listener IDs in use */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 643f065..90fdbff 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1136,7 +1136,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
init_new_proxy(curproxy);
curproxy->next = proxy;
proxy = curproxy;
- curproxy->conf.file = file;
+ curproxy->conf.file = strdup(file);
curproxy->conf.line = linenum;
curproxy->last_change = now.tv_sec;
curproxy->id = strdup(args[1]);
@@ -3425,7 +3425,7 @@ stats_error_parsing:
newsrv->next = curproxy->srv;
curproxy->srv = newsrv;
newsrv->proxy = curproxy;
- newsrv->conf.file = file;
+ newsrv->conf.file = strdup(file);
newsrv->conf.line = linenum;
LIST_INIT(&newsrv->pendconns);
diff --git a/src/haproxy.c b/src/haproxy.c
index 6141a5b..2944462 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -732,6 +732,7 @@ void deinit(void)
int i;
while (p) {
+ free(p->conf.file);
free(p->id);
free(p->check_req);
free(p->cookie_name);
--
1.7.1