[svn] commit: r3377 - in /branches/trac22/src/lib/python/isc/cc: data.py session.py tests/session_test.py

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Oct 27 15:04:38 UTC 2010


Author: jelte
Date: Wed Oct 27 15:04:37 2010
New Revision: 3377

Log:
addressed first 3 comments in #22

Modified:
    branches/trac22/src/lib/python/isc/cc/data.py
    branches/trac22/src/lib/python/isc/cc/session.py
    branches/trac22/src/lib/python/isc/cc/tests/session_test.py

Modified: branches/trac22/src/lib/python/isc/cc/data.py
==============================================================================
--- branches/trac22/src/lib/python/isc/cc/data.py (original)
+++ branches/trac22/src/lib/python/isc/cc/data.py Wed Oct 27 15:04:37 2010
@@ -31,10 +31,8 @@
     to_remove = []
     if type(a) != dict or type(b) != dict:
         raise DataTypeError("Not a dict in remove_identical()")
-    for ka in a.keys():
-        if ka in b and a[ka] == b[ka]:
-            to_remove.append(ka)
-    for id in to_remove:
+    duplicate_keys = [key for key in a.keys() if key in b and a[key] == b[key]]
+    for id in duplicate_keys:
         del(a[id])
 
 def merge(orig, new):

Modified: branches/trac22/src/lib/python/isc/cc/session.py
==============================================================================
--- branches/trac22/src/lib/python/isc/cc/session.py (original)
+++ branches/trac22/src/lib/python/isc/cc/session.py Wed Oct 27 15:04:37 2010
@@ -78,6 +78,8 @@
                 raise SessionError("Session has been closed.")
             if type(env) == dict:
                 env = isc.cc.message.to_wire(env)
+            if len(env) > 65535:
+                raise ProtocolError("Envelope too large")
             if type(msg) == dict:
                 msg = isc.cc.message.to_wire(msg)
             self._socket.setblocking(1)
@@ -113,9 +115,6 @@
                     if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
                         return env, msg
                     else:
-                        tmp = None
-                        if "reply" in env:
-                            tmp = env["reply"]
                         self._queue.append((env,msg))
                         return self.recvmsg(nonblock, seq)
                 else:

Modified: branches/trac22/src/lib/python/isc/cc/tests/session_test.py
==============================================================================
--- branches/trac22/src/lib/python/isc/cc/tests/session_test.py (original)
+++ branches/trac22/src/lib/python/isc/cc/tests/session_test.py Wed Oct 27 15:04:37 2010
@@ -137,6 +137,11 @@
         sess.close()
         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):
         sess = MySession()
         sess.sendmsg({}, {"hello": "a"})




More information about the bind10-changes mailing list