mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
Issue #7019: An attempt to unmarshal bad long data could produce
unnormalized PyLong objects; make it raise ValueError instead.
This commit is contained in:
parent
7664bfe4e2
commit
c3a12775e2
3 changed files with 10 additions and 1 deletions
|
@ -262,6 +262,11 @@ class BugsTestCase(unittest.TestCase):
|
||||||
testString = 'abc' * size
|
testString = 'abc' * size
|
||||||
marshal.dumps(testString)
|
marshal.dumps(testString)
|
||||||
|
|
||||||
|
def test_invalid_longs(self):
|
||||||
|
# Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs
|
||||||
|
invalid_string = 'l\x02\x00\x00\x00\x00\x00\x00\x00'
|
||||||
|
self.assertRaises(ValueError, marshal.loads, invalid_string)
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(IntTestCase,
|
test_support.run_unittest(IntTestCase,
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.6.4a1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #7019: Raise ValueError when unmarshalling bad long data, instead
|
||||||
|
of producing internally inconsistent Python longs.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -589,7 +589,8 @@ r_object(RFILE *p)
|
||||||
ob->ob_size = n;
|
ob->ob_size = n;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
int digit = r_short(p);
|
int digit = r_short(p);
|
||||||
if (digit < 0) {
|
if (digit < 0 ||
|
||||||
|
(digit == 0 && i == size-1)) {
|
||||||
Py_DECREF(ob);
|
Py_DECREF(ob);
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"bad marshal data");
|
"bad marshal data");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue