diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-23 13:19:23 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-23 13:19:23 (GMT) |
commit | 4409c6cfae2faa9217902ea720c1cf2d6f2b4fd2 (patch) | |
tree | d310ad189a5fe880965f8121b06d943858af84c2 /Modules/_pickle.c | |
parent | 3715cab3cb6bc689c66e7aaaeb86fbf953fe0262 (diff) | |
parent | e9b3074cf931fee3cb91638cbdd694fa9eb9614b (diff) | |
download | cpython-4409c6cfae2faa9217902ea720c1cf2d6f2b4fd2.zip cpython-4409c6cfae2faa9217902ea720c1cf2d6f2b4fd2.tar.gz cpython-4409c6cfae2faa9217902ea720c1cf2d6f2b4fd2.tar.bz2 |
Issue #23914: Fixed SystemError raised by unpickler on broken pickle data.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 5f38500..05afd06 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -459,8 +459,8 @@ Pdata_grow(Pdata *self) static PyObject * Pdata_pop(Pdata *self) { - PickleState *st = _Pickle_GetGlobalState(); if (Py_SIZE(self) == 0) { + PickleState *st = _Pickle_GetGlobalState(); PyErr_SetString(st->UnpicklingError, "bad pickle data"); return NULL; } @@ -5148,6 +5148,9 @@ load_obj(UnpicklerObject *self) if ((i = marker(self)) < 0) return -1; + if (Py_SIZE(self->stack) - i < 1) + return stack_underflow(); + args = Pdata_poptuple(self->stack, i + 1); if (args == NULL) return -1; @@ -5806,13 +5809,18 @@ do_append(UnpicklerObject *self, Py_ssize_t x) static int load_append(UnpicklerObject *self) { + if (Py_SIZE(self->stack) - 1 <= 0) + return stack_underflow(); return do_append(self, Py_SIZE(self->stack) - 1); } static int load_appends(UnpicklerObject *self) { - return do_append(self, marker(self)); + Py_ssize_t i = marker(self); + if (i < 0) + return -1; + return do_append(self, i); } static int @@ -5862,7 +5870,10 @@ load_setitem(UnpicklerObject *self) static int load_setitems(UnpicklerObject *self) { - return do_setitems(self, marker(self)); + Py_ssize_t i = marker(self); + if (i < 0) + return -1; + return do_setitems(self, i); } static int @@ -5872,6 +5883,8 @@ load_additems(UnpicklerObject *self) Py_ssize_t mark, len, i; mark = marker(self); + if (mark < 0) + return -1; len = Py_SIZE(self->stack); if (mark > len || mark <= 0) return stack_underflow(); |