BUG/MINOR: Fix several leaks of 'log_tag' in init().
authorEric Salama <esalama@haproxy.com>
Fri, 2 Oct 2020 09:58:19 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 2 Oct 2020 13:50:26 +0000 (15:50 +0200)
commit7cea6065aca04c91fc5109e581f124a46b2b5242
tree67402f169b5a32f8b5e6a0460d604b2b0ad4b03f
parent1d0206e71f2c1d63b8323f64b51f2bbd64e078fd
BUG/MINOR: Fix several leaks of 'log_tag' in init().

We use chunk_initstr() to store the program name as the default log-tag.

If we use the log-tag directive in the config file, this chunk will be
destroyed and replaced. chunk_initstr() sets the chunk size to 0 so we
will free the chunk itself, but not its content.

This happens for a global section and also for a proxy.

We fix this by using chunk_initlen() instead of chunk_initstr().
We also check that the memory allocation was successfull, otherwise we quit.

This fixes github issue #850.
It can be backported as far as 1.9, with minor adjustments to includes.
src/cfgparse-global.c
src/cfgparse-listen.c
src/haproxy.c