diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-05-26 08:57:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 08:57:09 (GMT) |
commit | 5ff5edfef63b3dbc1abb004b3fa4b3db87e79ff9 (patch) | |
tree | 03e4559429d73720b0340d36a7b5452fc0198684 /Lib/test/test_struct.py | |
parent | c2a177adf3575d4eb81030fba851f78d7a8e3f51 (diff) | |
download | cpython-5ff5edfef63b3dbc1abb004b3fa4b3db87e79ff9.zip cpython-5ff5edfef63b3dbc1abb004b3fa4b3db87e79ff9.tar.gz cpython-5ff5edfef63b3dbc1abb004b3fa4b3db87e79ff9.tar.bz2 |
[3.8] bpo-35714: Reject null characters in struct format strings (GH-16928) (GH-20419)
struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55316f4c6ab451997902579aa69020b537c)
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 454082e..67e7c55 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -652,6 +652,13 @@ class StructTest(unittest.TestCase): s2 = struct.Struct(s.format.encode()) self.assertEqual(s2.format, s.format) + def test_issue35714(self): + # Embedded null characters should not be allowed in format strings. + for s in '\0', '2\0i', b'\0': + with self.assertRaisesRegex(struct.error, + 'embedded null character'): + struct.calcsize(s) + class UnpackIteratorTest(unittest.TestCase): """ |