From c63369e999b458ecbd559bdde895c344b4db2841 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 22 Nov 2019 14:08:35 +0800 Subject: [PATCH] updat HISTORY --- HISTORY.rst | 2 ++ psutil/_pslinux.py | 5 ++--- psutil/tests/test_linux.py | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 045bb5d5f..1d3b34a24 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ XXXX-XX-XX **Bug fixes** +- 1179_: [Linux] Process cmdline() now takes into account misbehaving processes + renaming the command line and using inappropriate chars to separate args. - 1595_: [Windows] Process.kill() may not throw AccessDenied. - 1616_: use of Py_DECREF instead of Py_CLEAR will result in double free and segfault (CVE). (patch by Riccardo Schirone) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 80fbf8bfd..a56ead369 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1651,9 +1651,8 @@ def cmdline(self): data = data[:-1] cmdline = data.split(sep) # Sometimes last char is a null byte '\0' but the args are - # separated by spaces, see: - # https://github.com/giampaolo/psutil/ - # issues/1179#issuecomment-552984549 + # separated by spaces, see: https://github.com/giampaolo/psutil/ + # issues/1179#issuecomment-552984549 if sep == '\x00' and len(cmdline) == 1 and ' ' in data: cmdline = data.split(' ') return cmdline diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index ccde735d8..4d9cea924 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -1838,6 +1838,8 @@ def test_cmdline_spaces_mocked(self): assert m.called def test_cmdline_mixed_separators(self): + # https://github.com/giampaolo/psutil/issues/ + # 1179#issuecomment-552984549 p = psutil.Process() fake_file = io.StringIO(u('foo\x20bar\x00')) with mock.patch('psutil._common.open',