Commit 3fe5cad0 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

addressed first 3 comments in #22


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac22@3377 e5f2f494-b856-4b98-b285-d166d9295462
parent dd47ffa1
...@@ -31,10 +31,8 @@ def remove_identical(a, b): ...@@ -31,10 +31,8 @@ def remove_identical(a, b):
to_remove = [] to_remove = []
if type(a) != dict or type(b) != dict: if type(a) != dict or type(b) != dict:
raise DataTypeError("Not a dict in remove_identical()") raise DataTypeError("Not a dict in remove_identical()")
for ka in a.keys(): duplicate_keys = [key for key in a.keys() if key in b and a[key] == b[key]]
if ka in b and a[ka] == b[ka]: for id in duplicate_keys:
to_remove.append(ka)
for id in to_remove:
del(a[id]) del(a[id])
def merge(orig, new): def merge(orig, new):
......
...@@ -78,6 +78,8 @@ class Session: ...@@ -78,6 +78,8 @@ class Session:
raise SessionError("Session has been closed.") raise SessionError("Session has been closed.")
if type(env) == dict: if type(env) == dict:
env = isc.cc.message.to_wire(env) env = isc.cc.message.to_wire(env)
if len(env) > 65535:
raise ProtocolError("Envelope too large")
if type(msg) == dict: if type(msg) == dict:
msg = isc.cc.message.to_wire(msg) msg = isc.cc.message.to_wire(msg)
self._socket.setblocking(1) self._socket.setblocking(1)
...@@ -113,9 +115,6 @@ class Session: ...@@ -113,9 +115,6 @@ class Session:
if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]): if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
return env, msg return env, msg
else: else:
tmp = None
if "reply" in env:
tmp = env["reply"]
self._queue.append((env,msg)) self._queue.append((env,msg))
return self.recvmsg(nonblock, seq) return self.recvmsg(nonblock, seq)
else: else:
......
...@@ -137,6 +137,11 @@ class testSession(unittest.TestCase): ...@@ -137,6 +137,11 @@ class testSession(unittest.TestCase):
sess.close() sess.close()
self.assertRaises(SessionError, sess.sendmsg, {}, {"hello": "a"}) self.assertRaises(SessionError, sess.sendmsg, {}, {"hello": "a"})
def test_env_too_large(self):
sess = MySession()
largeenv = { "a": "b"*65535 }
self.assertRaises(ProtocolError, sess.sendmsg, largeenv, {"hello": "a"})
def test_session_sendmsg(self): def test_session_sendmsg(self):
sess = MySession() sess = MySession()
sess.sendmsg({}, {"hello": "a"}) sess.sendmsg({}, {"hello": "a"})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment