diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 19:10:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-29 19:10:07 (GMT) |
commit | e060619d4b047fdee613cafc64e3a9242a68ea54 (patch) | |
tree | 11c55e928773fe9e11be79432c5d28606290c137 /Modules | |
parent | d455a50773eb1f4531882a0b99ff7a253ad1d41e (diff) | |
download | cpython-e060619d4b047fdee613cafc64e3a9242a68ea54.zip cpython-e060619d4b047fdee613cafc64e3a9242a68ea54.tar.gz cpython-e060619d4b047fdee613cafc64e3a9242a68ea54.tar.bz2 |
Issue #25262. Added support for BINBYTES8 opcode in Python implementation of
unpickler. Highest 32 bits of 64-bit size for BINUNICODE8 and BINBYTES8
opcodes no longer silently ignored on 32-bit platforms in C implementation.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_pickle.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index c6cb8bc..830479f 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4540,7 +4540,17 @@ calc_binsize(char *bytes, int nbytes) int i; size_t x = 0; - for (i = 0; i < nbytes && i < sizeof(size_t); i++) { + if (nbytes > (int)sizeof(size_t)) { + /* Check for integer overflow. BINBYTES8 and BINUNICODE8 opcodes + * have 64-bit size that can't be represented on 32-bit platform. + */ + for (i = (int)sizeof(size_t); i < nbytes; i++) { + if (s[i]) + return -1; + } + nbytes = (int)sizeof(size_t); + } + for (i = 0; i < nbytes; i++) { x |= (size_t) s[i] << (8 * i); } |