FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
msgpack-python/test/test_seq.py at master · talent-source-code/msgpack-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
talent-source-code
/
msgpack-python
Public
forked from
msgpack/msgpack-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
msgpack-python
/
test
/
test_seq.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (28 loc) · 1.23 KB
Breadcrumbs
msgpack-python
/
test
/
test_seq.py
Copy path
File metadata and controls
41 lines (28 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# coding: utf-8
import
io
import
msgpack
binarydata
=
bytes
(
bytearray
(
range
(
256
)))
def
gen_binary_data
(
idx
):
return
binarydata
[:
idx
%
300
]
def
test_exceeding_unpacker_read_size
():
dumpf
=
io
.
BytesIO
()
packer
=
msgpack
.
Packer
()
NUMBER_OF_STRINGS
=
6
read_size
=
16
# 5 ok for read_size=16, while 6 glibc detected *** python: double free or corruption (fasttop):
# 20 ok for read_size=256, while 25 segfaults / glibc detected *** python: double free or corruption (!prev)
# 40 ok for read_size=1024, while 50 introduces errors
# 7000 ok for read_size=1024*1024, while 8000 leads to glibc detected *** python: double free or corruption (!prev):
for
idx
in
range
(
NUMBER_OF_STRINGS
):
data
=
gen_binary_data
(
idx
)
dumpf
.
write
(
packer
.
pack
(
data
))
f
=
io
.
BytesIO
(
dumpf
.
getvalue
())
dumpf
.
close
()
unpacker
=
msgpack
.
Unpacker
(
f
,
read_size
=
read_size
,
use_list
=
1
)
read_count
=
0
for
idx
,
o
in
enumerate
(
unpacker
):
assert
type
(
o
)
==
bytes
assert
o
==
gen_binary_data
(
idx
)
read_count
+=
1
assert
read_count
==
NUMBER_OF_STRINGS
Back
|
FazBrowse Home
|
New Git URL