diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-09-26 07:09:39 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-09-26 07:09:39 (GMT) |
commit | 5b8854eee0d81fdc56e38a1356fd4a0972d231bc (patch) | |
tree | 7e20b7cfae3fac349947512c883af728e89edc53 /Modules | |
parent | 00d4442979af67735b90a70d21168b14eb84b43e (diff) | |
parent | 03c59b9bef7ca78dd852d2fad381ee0a0dd17e22 (diff) | |
download | cpython-5b8854eee0d81fdc56e38a1356fd4a0972d231bc.zip cpython-5b8854eee0d81fdc56e38a1356fd4a0972d231bc.tar.gz cpython-5b8854eee0d81fdc56e38a1356fd4a0972d231bc.tar.bz2 |
merge 3.5
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_pickle.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 3ad9a97..c3f1896 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1193,6 +1193,12 @@ _Unpickler_Read(UnpicklerObject *self, char **s, Py_ssize_t n) { Py_ssize_t num_read; + if (self->next_read_idx > PY_SSIZE_T_MAX - n) { + PickleState *st = _Pickle_GetGlobalState(); + PyErr_SetString(st->UnpicklingError, + "read would overflow (invalid bytecode)"); + return -1; + } if (self->next_read_idx + n <= self->input_len) { *s = self->input_buffer + self->next_read_idx; self->next_read_idx += n; |