Kaydet (Commit) 584f5cbf authored tarafından Benjamin Peterson's avatar Benjamin Peterson

merge 3.3

...@@ -91,5 +91,9 @@ class TestDecode: ...@@ -91,5 +91,9 @@ class TestDecode:
self.assertEqual(self.loads(bom_in_str), '\ufeff') self.assertEqual(self.loads(bom_in_str), '\ufeff')
self.assertEqual(self.json.load(StringIO(bom_in_str)), '\ufeff') self.assertEqual(self.json.load(StringIO(bom_in_str)), '\ufeff')
def test_negative_index(self):
d = self.json.JSONDecoder()
self.assertRaises(ValueError, d.raw_decode, 'a'*42, -50000)
class TestPyDecode(TestDecode, PyTest): pass class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass class TestCDecode(TestDecode, CTest): pass
...@@ -1372,6 +1372,7 @@ Johannes Vogel ...@@ -1372,6 +1372,7 @@ Johannes Vogel
Alex Volkov Alex Volkov
Martijn Vries Martijn Vries
Sjoerd de Vries Sjoerd de Vries
Guido Vranken
Niki W. Waibel Niki W. Waibel
Wojtek Walczak Wojtek Walczak
Charles Waldman Charles Waldman
......
...@@ -27,6 +27,9 @@ Core and Builtins ...@@ -27,6 +27,9 @@ Core and Builtins
Library Library
------- -------
- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second
parameter. Bug reported by Guido Vranken.
- Issue #21169: getpass now handles non-ascii characters that the - Issue #21169: getpass now handles non-ascii characters that the
input stream encoding cannot encode by re-encoding using the input stream encoding cannot encode by re-encoding using the
replace error handler. replace error handler.
......
...@@ -941,7 +941,10 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_ ...@@ -941,7 +941,10 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
kind = PyUnicode_KIND(pystr); kind = PyUnicode_KIND(pystr);
length = PyUnicode_GET_LENGTH(pystr); length = PyUnicode_GET_LENGTH(pystr);
if (idx >= length) { if (idx < 0)
/* Compatibility with Python version. */
idx += length;
if (idx < 0 || idx >= length) {
raise_stop_iteration(idx); raise_stop_iteration(idx);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment