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
7b0ea78c
Commit
7b0ea78c
authored
Apr 13, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in scan_once, prevent the reading of arbitrary memory when passed a negative index
Bug reported by Guido Vranken.
parent
a5f43f6e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
1 deletion
+12
-1
Lib/test/json_tests/test_decode.py
Lib/test/json_tests/test_decode.py
+4
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_json.c
Modules/_json.c
+4
-1
No files found.
Lib/test/json_tests/test_decode.py
View file @
7b0ea78c
...
...
@@ -70,5 +70,9 @@ class TestDecode:
msg
=
'escape'
self
.
assertRaisesRegex
(
ValueError
,
msg
,
self
.
loads
,
s
)
def
test_negative_index
(
self
):
d
=
self
.
json
.
JSONDecoder
()
self
.
assertRaises
(
ValueError
,
d
.
raw_decode
,
'a'
*
42
,
-
50000
)
class
TestPyDecode
(
TestDecode
,
PyTest
):
pass
class
TestCDecode
(
TestDecode
,
CTest
):
pass
Misc/ACKS
View file @
7b0ea78c
...
...
@@ -1139,6 +1139,7 @@ Frank Visser
Johannes Vogel
Martijn Vries
Sjoerd de Vries
Guido Vranken
Niki W. Waibel
Wojtek Walczak
Charles Waldman
...
...
Misc/NEWS
View file @
7b0ea78c
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.2.6?
Library
-------
- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second
parameter. Bug reported by Guido Vranken.
- Issue #21082: In os.makedirs, do not set the process-wide umask. Note this
changes behavior of makedirs when exist_ok=True.
...
...
Modules/_json.c
View file @
7b0ea78c
...
...
@@ -930,7 +930,10 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
PyObject
*
res
;
Py_UNICODE
*
str
=
PyUnicode_AS_UNICODE
(
pystr
);
Py_ssize_t
length
=
PyUnicode_GET_SIZE
(
pystr
);
if
(
idx
>=
length
)
{
if
(
idx
<
0
)
/* Compatibility with Python version. */
idx
+=
length
;
if
(
idx
<
0
||
idx
>=
length
)
{
PyErr_SetNone
(
PyExc_StopIteration
);
return
NULL
;
}
...
...
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