mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #23914: Fixed SystemError raised by unpickler on broken pickle data.
This commit is contained in:
parent
b6aa5375d5
commit
e9b3074cf9
4 changed files with 105 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue