mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32844: Fix a subprocess misredirection of a low fd (GH5689)
bpo-32844: subprocess: Fix a potential misredirection of a low fd to stderr. When redirecting, subprocess attempts to achieve the following state: each fd to be redirected to is less than or equal to the fd it is redirected from, which is necessary because redirection occurs in the ascending order of destination descriptors. It fails to do so in a couple of corner cases, for example, if 1 is redirected to 2 and 0 is closed in the parent.
This commit is contained in:
parent
de7a2f04d6
commit
0e7144b064
3 changed files with 53 additions and 1 deletions
|
@ -424,7 +424,7 @@ child_exec(char *const exec_array[],
|
|||
either 0, 1 or 2, it is possible that it is overwritten (#12607). */
|
||||
if (c2pwrite == 0)
|
||||
POSIX_CALL(c2pwrite = dup(c2pwrite));
|
||||
if (errwrite == 0 || errwrite == 1)
|
||||
while (errwrite == 0 || errwrite == 1)
|
||||
POSIX_CALL(errwrite = dup(errwrite));
|
||||
|
||||
/* Dup fds for child.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue