From: Antoine Pitrou Date: Mon, 15 Apr 2013 19:55:14 +0000 (+0200) Subject: Issue #17710: Fix pickle raising a SystemError on bogus input. X-Git-Tag: v3.4.0a1~910 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af94051a933b7fbd9c63b0a45cfba5247d92ac14;p=thirdparty%2FPython%2Fcpython.git Issue #17710: Fix pickle raising a SystemError on bogus input. --- af94051a933b7fbd9c63b0a45cfba5247d92ac14 diff --cc Lib/pickle.py index 998fce0a6bbf,161c2e9e74b9..a4acbe941e03 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@@ -902,11 -949,14 +902,11 @@@ class _Unpickler def load_string(self): orig = self.readline() rep = orig[:-1] - for q in (b'"', b"'"): # double or single quote - if rep.startswith(q): - if len(rep) < 2 or not rep.endswith(q): - raise ValueError("insecure string pickle") - rep = rep[len(q):-len(q)] - break + # Strip outermost quotes - if rep[0] == rep[-1] and rep[0] in b'"\'': ++ if len(rep) >= 2 and rep[0] == rep[-1] and rep[0] in b'"\'': + rep = rep[1:-1] else: - raise ValueError("insecure string pickle: %r" % orig) + raise ValueError("insecure string pickle") self.append(codecs.escape_decode(rep)[0] .decode(self.encoding, self.errors)) dispatch[STRING[0]] = load_string