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
0e48b6fd
Commit
0e48b6fd
authored
Jun 23, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid overflow with large buffer sizes and/or offsets (closes #21831)
parent
5ffa380d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
Lib/test/test_buffer.py
Lib/test/test_buffer.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/bufferobject.c
Objects/bufferobject.c
+2
-2
No files found.
Lib/test/test_buffer.py
View file @
0e48b6fd
...
@@ -4,6 +4,7 @@ For now, tests just new or changed functionality.
...
@@ -4,6 +4,7 @@ For now, tests just new or changed functionality.
"""
"""
import
sys
import
unittest
import
unittest
from
test
import
test_support
from
test
import
test_support
...
@@ -29,6 +30,11 @@ class BufferTests(unittest.TestCase):
...
@@ -29,6 +30,11 @@ class BufferTests(unittest.TestCase):
m
=
memoryview
(
b
)
# Should not raise an exception
m
=
memoryview
(
b
)
# Should not raise an exception
self
.
assertEqual
(
m
.
tobytes
(),
s
)
self
.
assertEqual
(
m
.
tobytes
(),
s
)
def
test_large_buffer_size_and_offset
(
self
):
data
=
bytearray
(
'hola mundo'
)
buf
=
buffer
(
data
,
sys
.
maxsize
,
sys
.
maxsize
)
self
.
assertEqual
(
buf
[:
4096
],
""
)
def
test_main
():
def
test_main
():
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
...
...
Misc/NEWS
View file @
0e48b6fd
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.8?
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.8?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #21831: Avoid integer overflow when large sizes and offsets are given to
the buffer type.
- Issue #1856: Avoid crashes and lockups when daemon threads run while the
- Issue #1856: Avoid crashes and lockups when daemon threads run while the
interpreter is shutting down; instead, these threads are now killed when they
interpreter is shutting down; instead, these threads are now killed when they
try to take the GIL.
try to take the GIL.
...
...
Objects/bufferobject.c
View file @
0e48b6fd
...
@@ -88,7 +88,7 @@ get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size,
...
@@ -88,7 +88,7 @@ get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size,
*
size
=
count
;
*
size
=
count
;
else
else
*
size
=
self
->
b_size
;
*
size
=
self
->
b_size
;
if
(
offset
+
*
size
>
coun
t
)
if
(
*
size
>
count
-
offse
t
)
*
size
=
count
-
offset
;
*
size
=
count
-
offset
;
}
}
return
1
;
return
1
;
...
...
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