mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #17710: Fix pickle raising a SystemError on bogus input.
This commit is contained in:
commit
af94051a93
4 changed files with 15 additions and 5 deletions
|
|
@ -4205,7 +4205,7 @@ load_string(UnpicklerObject *self)
|
|||
|
||||
if ((len = _Unpickler_Readline(self, &s)) < 0)
|
||||
return -1;
|
||||
if (len < 3)
|
||||
if (len < 2)
|
||||
return bad_readline();
|
||||
if ((s = strdup(s)) == NULL) {
|
||||
PyErr_NoMemory();
|
||||
|
|
@ -4213,14 +4213,14 @@ load_string(UnpicklerObject *self)
|
|||
}
|
||||
|
||||
/* Strip outermost quotes */
|
||||
while (s[len - 1] <= ' ')
|
||||
while (len > 0 && s[len - 1] <= ' ')
|
||||
len--;
|
||||
if (s[0] == '"' && s[len - 1] == '"') {
|
||||
if (len > 1 && s[0] == '"' && s[len - 1] == '"') {
|
||||
s[len - 1] = '\0';
|
||||
p = s + 1;
|
||||
len -= 2;
|
||||
}
|
||||
else if (s[0] == '\'' && s[len - 1] == '\'') {
|
||||
else if (len > 1 && s[0] == '\'' && s[len - 1] == '\'') {
|
||||
s[len - 1] = '\0';
|
||||
p = s + 1;
|
||||
len -= 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue