Commits

Armin Rigo committed 35e27c3

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

Comments (0)

Files changed (2)

lib_pypy/_marshal.py

 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

lib_pypy/pypy_test/test_marshal_extra.py

         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)