diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-23 13:17:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-23 13:17:43 (GMT) |
commit | e9b3074cf931fee3cb91638cbdd694fa9eb9614b (patch) | |
tree | 15dcac1d410ece6390346e8d58a4b416d5dd37f4 /Modules/_pickle.c | |
parent | b6aa5375d5a2f81370338357506034befe62aa31 (diff) | |
download | cpython-e9b3074cf931fee3cb91638cbdd694fa9eb9614b.zip cpython-e9b3074cf931fee3cb91638cbdd694fa9eb9614b.tar.gz cpython-e9b3074cf931fee3cb91638cbdd694fa9eb9614b.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 8a98f51..d3bc420 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -448,8 +448,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; } @@ -5079,6 +5079,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; @@ -5737,13 +5740,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 @@ -5793,7 +5801,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 @@ -5803,6 +5814,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(); |