summaryrefslogtreecommitdiffstats
path: root/Demo/rpc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-12-19 00:06:17 (GMT)
committerGuido van Rossum <guido@python.org>1992-12-19 00:06:17 (GMT)
commitc91d60a640dc8018dfa48aefd65592cf17476cc3 (patch)
tree875ec6e4ab30c3a114c4a1ea17630a64e75f2e7d /Demo/rpc
parent424c673d2f517851f6b8b072725ed148565c5fdc (diff)
downloadcpython-c91d60a640dc8018dfa48aefd65592cf17476cc3.zip
cpython-c91d60a640dc8018dfa48aefd65592cf17476cc3.tar.gz
cpython-c91d60a640dc8018dfa48aefd65592cf17476cc3.tar.bz2
Changes to protect servers against broken clients
Diffstat (limited to 'Demo/rpc')
-rw-r--r--Demo/rpc/xdr.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Demo/rpc/xdr.py b/Demo/rpc/xdr.py
index bee88b4..83fde30 100644
--- a/Demo/rpc/xdr.py
+++ b/Demo/rpc/xdr.py
@@ -89,6 +89,8 @@ class Unpacker:
i = self.pos
self.pos = j = i+4
data = self.buf[i:j]
+ if len(data) < 4:
+ raise EOFError
x = long(ord(data[0]))<<24 | ord(data[1])<<16 | \
ord(data[2])<<8 | ord(data[3])
# Return a Python long only if the value is not representable
@@ -99,7 +101,10 @@ class Unpacker:
def unpack_uint(self):
i = self.pos
self.pos = j = i+4
- return struct.unpack('l', self.buf[i:j])
+ data = self.buf[i:j]
+ if len(data) < 4:
+ raise EOFError
+ return struct.unpack('l', data)
def unpack_int(self):
x = self.unpack_uint()
@@ -126,7 +131,7 @@ class Unpacker:
i = self.pos
j = i + (n+3)/4*4
if j > len(self.buf):
- raise RuntimeError, 'buffer overrun'
+ raise EOFError
self.pos = j
return self.buf[i:i+n]