summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@ispras.ru>2020-10-26 00:09:32 (GMT)
committerGitHub <noreply@github.com>2020-10-26 00:09:32 (GMT)
commitc0590c0033e86f98cdf5f2ca6898656f98ab4053 (patch)
treebf2e01413ef7171bfc87b0802a201635515c2413 /Lib/test
parente68c67805e6a4c4ec80bea64be0e8373cc02d322 (diff)
downloadcpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.zip
cpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.tar.gz
cpython-c0590c0033e86f98cdf5f2ca6898656f98ab4053.tar.bz2
bpo-42146: Fix memory leak in subprocess.Popen() in case of uid/gid overflow (GH-22966)
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`.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_subprocess.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 9fc4434..e25474a 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1895,6 +1895,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)
@@ -1938,6 +1942,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)
@@ -1986,6 +1994,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,