Improve security when using cPickle

This commit is contained in:
Cédric Krier committed 2008-02-04 23:16:28 +01:00
1 parent 6c17ac1e7a
commit b3a797ae7e
1 file changed
+5 -1
+5 -1
View File
@@ -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]))