BUG/MINOR: mworker: stop doing strtok directly from the env
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Feb 2023 11:44:56 +0000 (12:44 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Feb 2023 12:53:33 +0000 (13:53 +0100)
commitd27f457eea470117c608bf9d1a3bd42bcdb8e5dd
treec4e1543047bade8ad3d713c4c6364eafa8887410
parent4ad6ee94ab6d4b0d9d51065c8e9078ca018d4d1f
BUG/MINOR: mworker: stop doing strtok directly from the env

When parsing the HAPROXY_PROCESSES environement variable, strtok was
done directly from the ptr resulting from getenv(), which replaces the ;
by \0, showing confusing environment variables when debugging in /proc
or in a corefile.

Example:

(gdb) x/39s *environ
[...]
0x7fff6935af64: "HAPROXY_PROCESSES=|type=w"
0x7fff6935af7e: "fd=3"
0x7fff6935af83: "pid=4444"
0x7fff6935af8d: "rpid=1"
0x7fff6935af94: "reloads=0"
0x7fff6935af9e: "timestamp=1676338060"
0x7fff6935afb3: "id="
0x7fff6935afb7: "version=2.4.0-8076da-1010+11"

This patch fixes the issue by doing a strdup on the variable.

Could be backported in previous versions (mworker_proc_to_env_list
exists since 1.9)
src/mworker.c