mirror of
https://github.com/python/cpython.git
synced 2025-12-10 02:50:09 +00:00
[security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner. Add private C API function _PyUnicode_AsUnicode() which is similar to PyUnicode_AsUnicode(), but checks for null characters.
This commit is contained in:
parent
592eda1233
commit
f7eae0adfc
22 changed files with 115 additions and 23 deletions
|
|
@ -151,6 +151,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, __import__, 1, 2, 3, 4)
|
||||
self.assertRaises(ValueError, __import__, '')
|
||||
self.assertRaises(TypeError, __import__, 'sys', name='sys')
|
||||
# embedded null character
|
||||
self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
|
||||
|
||||
def test_abs(self):
|
||||
# int
|
||||
|
|
@ -1010,6 +1012,10 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(fp.read(300), 'XXX'*100)
|
||||
self.assertEqual(fp.read(1000), 'YYY'*100)
|
||||
|
||||
# embedded null bytes and characters
|
||||
self.assertRaises(ValueError, open, 'a\x00b')
|
||||
self.assertRaises(ValueError, open, b'a\x00b')
|
||||
|
||||
def test_open_default_encoding(self):
|
||||
old_environ = dict(os.environ)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue