commit | 3e4e72f66f4e9d379d7734b5d0de92fc0b4d9596 | [log] [tgz] |
---|---|---|
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | Tue Nov 11 20:05:06 2008 +0000 |
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | Tue Nov 11 20:05:06 2008 +0000 |
tree | 4eee1f9789483a66f079269f0c3c2f194b5910be | |
parent | 3bae65bacdc7c03e665fabb2065c740358ac362f [diff] [blame] |
#4298: pickle.load() can segfault on invalid or truncated input. Patch and test by Hirokazu Yamamoto.
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index a689c33..c1facd8 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c
@@ -489,6 +489,11 @@ return -1; } + if (PyBytes_GET_SIZE(data) != n) { + PyErr_SetNone(PyExc_EOFError); + return -1; + } + Py_XDECREF(self->last_string); self->last_string = data;