[Python-checkins] r75203 - in python/branches/release26-maint: Lib/test/test_marshal.py Misc/NEWS Python/marshal.c
mark.dickinson
python-checkins at python.org
Sat Oct 3 10:15:49 CEST 2009
Author: mark.dickinson
Date: Sat Oct 3 10:15:49 2009
New Revision: 75203
Log:
Issue #7019: An attempt to unmarshal bad long data could produce
unnormalized PyLong objects; make it raise ValueError instead.
Modified:
python/branches/release26-maint/Lib/test/test_marshal.py
python/branches/release26-maint/Misc/NEWS
python/branches/release26-maint/Python/marshal.c
Modified: python/branches/release26-maint/Lib/test/test_marshal.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_marshal.py (original)
+++ python/branches/release26-maint/Lib/test/test_marshal.py Sat Oct 3 10:15:49 2009
@@ -262,6 +262,11 @@
testString = 'abc' * size
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():
test_support.run_unittest(IntTestCase,
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Sat Oct 3 10:15:49 2009
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #7019: Raise ValueError when unmarshalling bad long data, instead
+ of producing internally inconsistent Python longs.
+
Library
-------
Modified: python/branches/release26-maint/Python/marshal.c
==============================================================================
--- python/branches/release26-maint/Python/marshal.c (original)
+++ python/branches/release26-maint/Python/marshal.c Sat Oct 3 10:15:49 2009
@@ -589,7 +589,8 @@
ob->ob_size = n;
for (i = 0; i < size; i++) {
int digit = r_short(p);
- if (digit < 0) {
+ if (digit < 0 ||
+ (digit == 0 && i == size-1)) {
Py_DECREF(ob);
PyErr_SetString(PyExc_ValueError,
"bad marshal data");
More information about the Python-checkins
mailing list