mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Issue #12847: Fix a crash with negative PUT and LONG_BINPUT arguments in
the C pickle implementation.
This commit is contained in:
commit
a514eb95f3
4 changed files with 31 additions and 1 deletions
|
@ -1154,16 +1154,22 @@ class _Unpickler:
|
|||
|
||||
def load_put(self):
|
||||
i = int(self.readline()[:-1])
|
||||
if i < 0:
|
||||
raise ValueError("negative PUT argument")
|
||||
self.memo[i] = self.stack[-1]
|
||||
dispatch[PUT[0]] = load_put
|
||||
|
||||
def load_binput(self):
|
||||
i = self.read(1)[0]
|
||||
if i < 0:
|
||||
raise ValueError("negative BINPUT argument")
|
||||
self.memo[i] = self.stack[-1]
|
||||
dispatch[BINPUT[0]] = load_binput
|
||||
|
||||
def load_long_binput(self):
|
||||
i = mloads(b'i' + self.read(4))
|
||||
if i < 0:
|
||||
raise ValueError("negative LONG_BINPUT argument")
|
||||
self.memo[i] = self.stack[-1]
|
||||
dispatch[LONG_BINPUT[0]] = load_long_binput
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue