Issue #12847: Fix a crash with negative PUT and LONG_BINPUT arguments in

the C pickle implementation.
This commit is contained in:
Antoine Pitrou 2011-08-30 00:28:40 +02:00
commit a514eb95f3
4 changed files with 31 additions and 1 deletions

View file

@ -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