mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
[3.9] bpo-42146: Fix memory leak in subprocess.Popen() in case of uid/gid overflow (GH-22966) (GH-22980)
Fix memory leak in subprocess.Popen() in case of uid/gid overflow
Also add a test that would catch this leak with `--huntrleaks`.
Alas, the test for `extra_groups` also exposes an inconsistency
in our error reporting: we use a custom ValueError for `extra_groups`,
but propagate OverflowError for `user` and `group`.
(cherry picked from commit c0590c0033
)
Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Automerge-Triggered-By: GH:gpshead
This commit is contained in:
parent
0b290dd217
commit
c12afa92b0
3 changed files with 17 additions and 2 deletions
|
@ -1826,6 +1826,10 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD, user=-1)
|
||||
|
||||
with self.assertRaises(OverflowError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD,
|
||||
cwd=os.curdir, env=os.environ, user=2**64)
|
||||
|
||||
if pwd is None and name_uid is not None:
|
||||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD, user=name_uid)
|
||||
|
@ -1869,6 +1873,10 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD, group=-1)
|
||||
|
||||
with self.assertRaises(OverflowError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD,
|
||||
cwd=os.curdir, env=os.environ, group=2**64)
|
||||
|
||||
if grp is None:
|
||||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD, group=name_group)
|
||||
|
@ -1917,6 +1925,11 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD, extra_groups=[-1])
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD,
|
||||
cwd=os.curdir, env=os.environ,
|
||||
extra_groups=[2**64])
|
||||
|
||||
if grp is None:
|
||||
with self.assertRaises(ValueError):
|
||||
subprocess.check_call(ZERO_RETURN_CMD,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue