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
9f9a00af
Commit
9f9a00af
authored
Sep 03, 2015
by
Larry Hastings
Browse files
Options
Browse Files
Download
Plain Diff
Merged in storchaka/cpython350 (pull request #13)
Issue #24989
parents
a43de00b
4e63f7a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
Lib/test/test_memoryio.py
Lib/test/test_memoryio.py
+13
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_io/bytesio.c
Modules/_io/bytesio.c
+5
-1
No files found.
Lib/test/test_memoryio.py
View file @
9f9a00af
...
...
@@ -166,6 +166,10 @@ class MemoryTestMixin:
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
read
(
None
),
buf
)
self
.
assertRaises
(
TypeError
,
memio
.
read
,
''
)
memio
.
seek
(
len
(
buf
)
+
1
)
self
.
assertEqual
(
memio
.
read
(
1
),
self
.
EOF
)
memio
.
seek
(
len
(
buf
)
+
1
)
self
.
assertEqual
(
memio
.
read
(),
self
.
EOF
)
memio
.
close
()
self
.
assertRaises
(
ValueError
,
memio
.
read
)
...
...
@@ -185,6 +189,9 @@ class MemoryTestMixin:
self
.
assertEqual
(
memio
.
readline
(
-
1
),
buf
)
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
readline
(
0
),
self
.
EOF
)
# Issue #24989: Buffer overread
memio
.
seek
(
len
(
buf
)
*
2
+
1
)
self
.
assertEqual
(
memio
.
readline
(),
self
.
EOF
)
buf
=
self
.
buftype
(
"1234567890
\
n
"
)
memio
=
self
.
ioclass
((
buf
*
3
)[:
-
1
])
...
...
@@ -217,6 +224,9 @@ class MemoryTestMixin:
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
readlines
(
None
),
[
buf
]
*
10
)
self
.
assertRaises
(
TypeError
,
memio
.
readlines
,
''
)
# Issue #24989: Buffer overread
memio
.
seek
(
len
(
buf
)
*
10
+
1
)
self
.
assertEqual
(
memio
.
readlines
(),
[])
memio
.
close
()
self
.
assertRaises
(
ValueError
,
memio
.
readlines
)
...
...
@@ -238,6 +248,9 @@ class MemoryTestMixin:
self
.
assertEqual
(
line
,
buf
)
i
+=
1
self
.
assertEqual
(
i
,
10
)
# Issue #24989: Buffer overread
memio
.
seek
(
len
(
buf
)
*
10
+
1
)
self
.
assertEqual
(
list
(
memio
),
[])
memio
=
self
.
ioclass
(
buf
*
2
)
memio
.
close
()
self
.
assertRaises
(
ValueError
,
memio
.
__next__
)
...
...
Misc/NEWS
View file @
9f9a00af
...
...
@@ -15,6 +15,9 @@ Core and Builtins
Library
-------
- Issue #24989: Fixed buffer overread in BytesIO.readline() if a position is
set beyond size. Based on patch by John Leitch.
- Issue #24913: Fix overrun error in deque.index().
Found by John Leitch and Bryce Darling.
...
...
Modules/_io/bytesio.c
View file @
9f9a00af
...
...
@@ -57,14 +57,18 @@ scan_eol(bytesio *self, Py_ssize_t len)
Py_ssize_t
maxlen
;
assert
(
self
->
buf
!=
NULL
);
assert
(
self
->
pos
>=
0
);
if
(
self
->
pos
>=
self
->
string_size
)
return
0
;
/* Move to the end of the line, up to the end of the string, s. */
start
=
PyBytes_AS_STRING
(
self
->
buf
)
+
self
->
pos
;
maxlen
=
self
->
string_size
-
self
->
pos
;
if
(
len
<
0
||
len
>
maxlen
)
len
=
maxlen
;
if
(
len
)
{
start
=
PyBytes_AS_STRING
(
self
->
buf
)
+
self
->
pos
;
n
=
memchr
(
start
,
'\n'
,
len
);
if
(
n
)
/* Get the length from the current position to the end of
...
...
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