mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #17872: Fix a segfault in marshal.load() when input stream returns
more bytes than requested.
This commit is contained in:
parent
244d6252f2
commit
3641a74e1c
3 changed files with 35 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
from test import support
|
||||
import array
|
||||
import io
|
||||
import marshal
|
||||
import sys
|
||||
import unittest
|
||||
|
@ -279,6 +280,17 @@ class BugsTestCase(unittest.TestCase):
|
|||
unicode_string = 'T'
|
||||
self.assertRaises(TypeError, marshal.loads, unicode_string)
|
||||
|
||||
def test_bad_reader(self):
|
||||
class BadReader(io.BytesIO):
|
||||
def read(self, n=-1):
|
||||
b = super().read(n)
|
||||
if n is not None and n > 4:
|
||||
b += b' ' * 10**6
|
||||
return b
|
||||
for value in (1.0, 1j, b'0123456789', '0123456789'):
|
||||
self.assertRaises(ValueError, marshal.load,
|
||||
BadReader(marshal.dumps(value)))
|
||||
|
||||
LARGE_SIZE = 2**31
|
||||
pointer_size = 8 if sys.maxsize > 0xFFFFFFFF else 4
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue