]> git.ipfire.org Git - thirdparty/make.git/commit
Always restore global environ if we use vfork
authorPaul Smith <psmith@gnu.org>
Sun, 25 Sep 2022 17:29:59 +0000 (13:29 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 25 Sep 2022 20:57:31 +0000 (16:57 -0400)
commitc4e232e44f00be75ba58bc5f12e7562a62028fe9
tree447d2ed4ac0886545837bf97994d985199953c71
parentaa99e810a9158e8c0ff8bb024c3dacc2722d0f18
Always restore global environ if we use vfork

We may change the global environ variable in the child; when using
vfork() this also sets it in the parent.  Preserve the parent's
environ in child_execute_job() so it takes effect for all callers.

Reported by Denis Excoffier <bug-tar@Denis-Excoffier.org>
Root cause found by Martin Dorey <Martin.Dorey@hitachivantara.com>

* src/job.c (start_job_command): Remove save/restore of the parent
environment.
(child_execute_job): Add save/restore of the parent environment,
if we use vfork().
* tests/scripts/functions/shell: Add a test the crashes if we don't
reset environ after we run $(shell ...).
src/job.c
tests/scripts/functions/shell