From: Christopher Faulet Date: Tue, 29 Aug 2017 14:46:57 +0000 (+0200) Subject: MEDIUM: chunks: Realloc trash buffers only after the config is parsed and checked X-Git-Tag: v1.8-dev3~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ef26398703a8f83a710278df8ec585ada161184;p=thirdparty%2Fhaproxy.git MEDIUM: chunks: Realloc trash buffers only after the config is parsed and checked Trash buffers are reallocated when "tune.bufsize" parameter is changed. Here, we just move the realloc after the configuration parsing. Given that the config parser doesn't rely on the trash size, it should be harmless. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 7e939eea19..c2115e6a2b 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -773,11 +773,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm) err_code |= ERR_ALERT | ERR_FATAL; goto out; } - if (!init_trash_buffers()) { - Alert("parsing [%s:%d] : failed to initialize trash buffers.\n", file, linenum); - err_code |= ERR_ALERT | ERR_FATAL; - goto out; - } } else if (!strcmp(args[0], "tune.maxrewrite")) { if (alertif_too_many_args(1, file, linenum, args, &err_code)) diff --git a/src/haproxy.c b/src/haproxy.c index c27fca0ddc..efc4da552a 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1712,6 +1712,12 @@ static void init(int argc, char **argv) if (global.nbproc < 1) global.nbproc = 1; + /* Realloc trash buffers because global.tune.bufsize may have changed */ + if (!init_trash_buffers()) { + Alert("failed to initialize trash buffers.\n"); + exit(1); + } + swap_buffer = calloc(1, global.tune.bufsize); get_http_auth_buff = calloc(1, global.tune.bufsize); static_table_key = calloc(1, sizeof(*static_table_key));