BUG/MINOR: tools: use my_unsetenv instead of unsetenv
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 26 Jun 2025 14:49:12 +0000 (16:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Aug 2025 06:29:38 +0000 (08:29 +0200)
commite29ba58d8dddfc834695d233fe8dd59e7c5409ca
tree7ce5aa76dc7e54234d0673373908da490cb43581
parentb66643125323412a64bcfe978edb617cca4c15ce
BUG/MINOR: tools: use my_unsetenv instead of unsetenv

Let's use our own implementation of unsetenv() instead of the one, which is
provided in libc. Implementation from libc may vary in dependency of UNIX
distro. Implemenation from libc.so.1 ported on Illumos (see the link below) has
caused an eternal loop in the clean_env(), where we invoke unsetenv().

(https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/gen/getenv.c#L411C1-L456C1)

This is reported at GitHUB #3018 and the reporter has proposed the patch, which
we really appreciate! But looking at his fix and to the implementations of
unsetenv() in FreeBSD libc and in Linux glibc 2.31, it seems, that the algorithm
of clean_env() will perform better with our my_unsetenv() implementation.

This should be backported in versions 3.1 and 3.2.

(cherry picked from commit a9afc10ae8741ac34bc049856de46d2891b7be27)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 09ba9ac74bd85059233e553452ce12b3ba724649)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/tools.c