Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fc05e68d
Commit
fc05e68d
authored
Jul 05, 2018
by
Serhiy Storchaka
Committed by
GitHub
Jul 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33720: Improve tests for the stack overflow in marshal.loads(). (GH-7336)
parent
3a9bb5f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
Lib/test/test_marshal.py
Lib/test/test_marshal.py
+17
-6
No files found.
Lib/test/test_marshal.py
View file @
fc05e68d
...
...
@@ -210,13 +210,24 @@ class BugsTestCase(unittest.TestCase):
except
Exception
:
pass
def
test_loads_2x_code
(
self
):
s
=
b'c'
+
(
b'X'
*
4
*
4
)
+
b'{'
*
2
**
20
self
.
assertRaises
(
ValueError
,
marshal
.
loads
,
s
)
def
test_loads_recursion
(
self
):
s
=
b'c'
+
(
b'X'
*
4
*
5
)
+
b'{'
*
2
**
20
def
run_tests
(
N
,
check
):
# (((...None...),),)
check
(
b')
\
x01
'
*
N
+
b'N'
)
check
(
b'(
\
x01
\
x00
\
x00
\
x00
'
*
N
+
b'N'
)
# [[[...None...]]]
check
(
b'[
\
x01
\
x00
\
x00
\
x00
'
*
N
+
b'N'
)
# {None: {None: {None: ...None...}}}
check
(
b'{N'
*
N
+
b'N'
+
b'0'
*
N
)
# frozenset([frozenset([frozenset([...None...])])])
check
(
b'>
\
x01
\
x00
\
x00
\
x00
'
*
N
+
b'N'
)
# Check that the generated marshal data is valid and marshal.loads()
# works for moderately deep nesting
run_tests
(
100
,
marshal
.
loads
)
# Very deeply nested structure shouldn't blow the stack
def
check
(
s
):
self
.
assertRaises
(
ValueError
,
marshal
.
loads
,
s
)
run_tests
(
2
**
20
,
check
)
def
test_recursion_limit
(
self
):
# Create a deeply nested structure.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment