[pypy-commit] pypy default: Test and fix (thanks J. Slenders on pypy-dev)

arigo noreply at buildbot.pypy.org
Wed Aug 8 23:59:33 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r56662:35e27c352e40
Date: 2012-08-08 23:59 +0200
http://bitbucket.org/pypy/pypy/changeset/35e27c352e40/

Log:	Test and fix (thanks J. Slenders on pypy-dev)

diff --git a/lib_pypy/_marshal.py b/lib_pypy/_marshal.py
--- a/lib_pypy/_marshal.py
+++ b/lib_pypy/_marshal.py
@@ -430,6 +430,7 @@
 def _read(self, n):
     pos = self.bufpos
     newpos = pos + n
+    if newpos > len(self.bufstr): raise EOFError
     ret = self.bufstr[pos : newpos]
     self.bufpos = newpos
     return ret
diff --git a/lib_pypy/pypy_test/test_marshal_extra.py b/lib_pypy/pypy_test/test_marshal_extra.py
--- a/lib_pypy/pypy_test/test_marshal_extra.py
+++ b/lib_pypy/pypy_test/test_marshal_extra.py
@@ -142,4 +142,6 @@
         f2.close()
     assert obj == case
 
-
+def test_load_truncated_string():
+    s = '(\x02\x00\x00\x00i\x03\x00\x00\x00sB\xf9\x00\x00\nabcd'
+    py.test.raises(EOFError, marshal.loads, s)


More information about the pypy-commit mailing list