]> git.lizzy.rs Git - rust.git/commit
Fixes #46775 -- don't mutate the process's environment in Command::exec
authorAlex Gaynor <alex.gaynor@gmail.com>
Thu, 25 Oct 2018 19:44:32 +0000 (19:44 +0000)
committerAlex Gaynor <alex.gaynor@gmail.com>
Thu, 1 Nov 2018 12:51:24 +0000 (12:51 +0000)
commit36fe3b605a7a7143a14565272140ba1b43c1b041
treeb6e50e01308ebee18923dbf6d22d3f81338549c5
parent365b9001e588cf3d91561894b0e44389e31ae000
Fixes #46775 -- don't mutate the process's environment in Command::exec

Instead, pass the environment to execvpe, so the kernel can apply it directly to the new process. This avoids a use-after-free in the case where exec'ing the new process fails for any reason, as well as a race condition if there are other threads alive during the exec.
src/libstd/sys/unix/process/process_common.rs
src/libstd/sys/unix/process/process_unix.rs
src/test/run-pass/command-exec.rs