Merged revisions 77355 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 7 Jan 2010 18:02:53 +0000 (18:02 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 7 Jan 2010 18:02:53 +0000 (18:02 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r77355 | antoine.pitrou | 2010-01-07 18:57:31 +0100 (jeu., 07 janv. 2010) | 18 lines

  Merged revisions 77352-77354 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r77352 | antoine.pitrou | 2010-01-07 18:46:49 +0100 (jeu., 07 janv. 2010) | 5 lines

    Issue #7455: Fix possible crash in cPickle on invalid input.  Patch by
    Florent Xicluna.
  ........
    r77353 | antoine.pitrou | 2010-01-07 18:49:37 +0100 (jeu., 07 janv. 2010) | 3 lines

    Fix attribution. Florent actually repackaged and reviewed Victor's patch (sorry!).
  ........
    r77354 | antoine.pitrou | 2010-01-07 18:54:10 +0100 (jeu., 07 janv. 2010) | 3 lines

    Fix reattribution mistake when fixing attribution mistake!
  ........
................

Lib/test/pickletester.py
Misc/NEWS
Modules/_pickle.c

index 19704ae7cedea2111643e01ace68689a70d022b6..7ecc1053d73c0c2162d626dd0b684eb4b40c2aa4 100644 (file)
@@ -1142,6 +1142,9 @@ class AbstractPickleModuleTests(unittest.TestCase):
         # Test issue4298
         s = bytes([0x58, 0, 0, 0, 0x54])
         self.assertRaises(EOFError, pickle.loads, s)
+        # Test issue7455
+        s = b'0'
+        self.assertRaises(pickle.UnpicklingError, pickle.loads, s)
 
 
 class AbstractPersistentPicklerTests(unittest.TestCase):
index ec4fa86eece3433f825bde0e8016ef1504049e20..eaef3117c3a8f08e6c749d6f859327ae719dcc50 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -61,6 +61,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #7455: Fix possible crash in cPickle on invalid input.  Patch by
+  Victor Stinner.
+
 - Issue #6511: ZipFile now raises BadZipfile (instead of an IOError) when
   opening an empty or very small file.
 
index 0e6df34bf1049d684c883af456cd05c2cefe669f..29aed7adb3b8d8ea4fbefeb1900d094038d6d180 100644 (file)
@@ -3729,7 +3729,7 @@ load_pop(UnpicklerObject *self)
      */
     if (self->num_marks > 0 && self->marks[self->num_marks - 1] == len) {
         self->num_marks--;
-    } else if (len >= 0) {
+    } else if (len > 0) {
         len--;
         Py_DECREF(self->stack->data[len]);
         self->stack->length = len;