mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
[3.6] bpo-30730: Prevent environment variables injection in subprocess on Windows. (GH-2325) (#2360)
Prevent passing other invalid environment variables and command arguments..
(cherry picked from commit d174d24a5d
)
This commit is contained in:
parent
1b7474dedc
commit
e7135751b8
5 changed files with 72 additions and 9 deletions
|
@ -1239,8 +1239,12 @@ class Popen(object):
|
|||
# and pass it to fork_exec()
|
||||
|
||||
if env is not None:
|
||||
env_list = [os.fsencode(k) + b'=' + os.fsencode(v)
|
||||
for k, v in env.items()]
|
||||
env_list = []
|
||||
for k, v in env.items():
|
||||
k = os.fsencode(k)
|
||||
if b'=' in k:
|
||||
raise ValueError("illegal environment variable name")
|
||||
env_list.append(k + b'=' + os.fsencode(v))
|
||||
else:
|
||||
env_list = None # Use execv instead of execve.
|
||||
executable = os.fsencode(executable)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue