summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-11-11 20:05:06 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-11-11 20:05:06 (GMT)
commit3e4e72f66f4e9d379d7734b5d0de92fc0b4d9596 (patch)
tree4eee1f9789483a66f079269f0c3c2f194b5910be /Modules/_pickle.c
parent3bae65bacdc7c03e665fabb2065c740358ac362f (diff)
downloadcpython-3e4e72f66f4e9d379d7734b5d0de92fc0b4d9596.zip
cpython-3e4e72f66f4e9d379d7734b5d0de92fc0b4d9596.tar.gz
cpython-3e4e72f66f4e9d379d7734b5d0de92fc0b4d9596.tar.bz2
#4298: pickle.load() can segfault on invalid or truncated input.
Patch and test by Hirokazu Yamamoto.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c5
1 files changed, 5 insertions, 0 deletions
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 @@ unpickler_read(UnpicklerObject *self, char **s, Py_ssize_t n)
return -1;
}
+ if (PyBytes_GET_SIZE(data) != n) {
+ PyErr_SetNone(PyExc_EOFError);
+ return -1;
+ }
+
Py_XDECREF(self->last_string);
self->last_string = data;