diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2014-07-03 10:58:06 -0500 |
---|---|---|
committer | Zachary Ware <zachary.ware@gmail.com> | 2014-07-03 10:58:06 -0500 |
commit | ad4690fcca5704277abece184d49b39a913029d4 (patch) | |
tree | 20fc0b168375bc7b17bc7b34f1b053cac40b908a /Lib/test/test_winreg.py | |
parent | 0d50af45b654784fe639ab6489f91e7524ed3ace (diff) | |
download | cpython-git-ad4690fcca5704277abece184d49b39a913029d4.tar.gz |
Issue #21151: Fixed a segfault in the winreg module.
When ``None`` was passed as a ``REG_BINARY`` value to SetValueEx,
PyMem_DEL was called on an uninitialized buffer. Patch by John Ehresman.
(Also an incidental typo fix in a comment in test_winreg)
Diffstat (limited to 'Lib/test/test_winreg.py')
-rw-r--r-- | Lib/test/test_winreg.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index ef4ce552f1..2c4ac08f39 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -341,7 +341,7 @@ class LocalWinregTests(BaseWinregTests): def test_queryvalueex_return_value(self): # Test for Issue #16759, return unsigned int from QueryValueEx. # Reg2Py, which gets called by QueryValueEx, was returning a value - # generated by PyLong_FromLong. The implmentation now uses + # generated by PyLong_FromLong. The implementation now uses # PyLong_FromUnsignedLong to match DWORD's size. try: with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: @@ -354,6 +354,19 @@ class LocalWinregTests(BaseWinregTests): finally: DeleteKey(HKEY_CURRENT_USER, test_key_name) + def test_setvalueex_crash_with_none_arg(self): + # Test for Issue #21151, segfault when None is passed to SetValueEx + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + test_val = None + SetValueEx(ck, "test_name", 0, REG_BINARY, test_val) + ret_val, ret_type = QueryValueEx(ck, "test_name") + self.assertEqual(ret_type, REG_BINARY) + self.assertEqual(ret_val, test_val) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + @unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests") |