Improve security when using cPickle
This commit is contained in:
1 parent
6c17ac1e7a
commit
b3a797ae7e
1 file changed
+5
-1
+5
-1
@@ -1,5 +1,6 @@
|
||||
import socket
|
||||
import cPickle
|
||||
import cStringIO
|
||||
|
||||
DNS_CACHE = {}
|
||||
|
||||
@@ -83,7 +84,10 @@ class PySocket:
|
||||
if chunk == '':
|
||||
raise RuntimeError, "socket connection broken"
|
||||
msg = msg + chunk
|
||||
res = cPickle.loads(msg)
|
||||
msgio = cStringIO.StringIO(msg)
|
||||
unpickler = cPickle.Unpickler(msgio)
|
||||
unpickler.find_global = None
|
||||
res = unpickler.load()
|
||||
if isinstance(res[0], Exception):
|
||||
if exception:
|
||||
raise PySocketException(str(res[0]), str(res[1]))
|
||||
|
||||
Reference in new issue
Block a user