]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: startup: fix UAF when set the default for log_tag
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 21 Nov 2024 15:21:54 +0000 (16:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Nov 2024 18:55:21 +0000 (19:55 +0100)
commit351ae5dbeda32a257d2970a140747107f750fe4e
treee7cc4f8db7265425dfbcde54888f3b8e4d67fd77
parentd1c3cd89743861e655ee52c031c8f92486fe96a8
BUG/MINOR: startup: fix UAF when set the default for log_tag

In the init_early() global.log_tag is initialized to the string from progname
pointer and global.log_tag.area points to this pointer.

If log-tag keyword is provided in the configuration, its parser at first frees
global.log_tag.area and then it does a new memory allocation to copy
there the argument of log-tag. So, progname no longer points to the valid
memory.

To fix this, let's always keep progname and global.log_tag.area at separate
memory areas. If log_tag will be redefined in the configuration, its parser will
free the memory allocated for the default value in chunk_destroy(). Memory
allocated for progname will be freed in deinit().

This should not be backported as related to the latest master-worker
refactoring.
src/haproxy.c