[Zope-Checkins] CVS: ZODB3/ZEO/zrpc - smac.py:1.42

Jeremy Hylton jeremy at zope.com
Wed Dec 17 17:52:11 EST 2003


Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv28494

Modified Files:
	smac.py 
Log Message:
Patch from kiko: Remember has_mac value across handle_read() calls.

The presence or absence of a mac bit is really part of the persistent
state of SizedMessageAsyncConnection.  If state is True when
handle_read() is entered, we get into the code to check the mac and
process the message without testing whether a mac is present.

I wish there was a test for this, but the code it's very difficult to
setup a test that calls handle_read() in just the right state.  A good
project, but not one I'm up for now.


=== ZODB3/ZEO/zrpc/smac.py 1.41 => 1.42 ===
--- ZODB3/ZEO/zrpc/smac.py:1.41	Fri Nov 28 11:44:49 2003
+++ ZODB3/ZEO/zrpc/smac.py	Wed Dec 17 17:52:11 2003
@@ -92,6 +92,7 @@
         # The next thing read is always of length __msg_size.
         # The state alternates between 0 and 1.
         self.__state = 0
+        self.__has_mac = True
         self.__msg_size = 4
         self.__output_lock = threading.Lock() # Protects __output
         self.__output = []
@@ -149,6 +150,7 @@
             input_len = self.__input_len + len(d)
             msg_size = self.__msg_size
             state = self.__state
+            has_mac = self.__has_mac
 
             inp = self.__inp
             if msg_size > input_len:
@@ -171,7 +173,6 @@
                 inp = "".join(inp)
 
             offset = 0
-            has_mac = 0
             while (offset + msg_size) <= input_len:
                 msg = inp[offset:offset + msg_size]
                 offset = offset + msg_size
@@ -208,9 +209,12 @@
                                                  % (_mac, mac))
                         else:
                             log("Received MAC but no session key set")
+                    elif self.__hmac_send:
+                        raise ValueError("Received message without MAC")
                     self.message_input(msg)
 
             self.__state = state
+            self.__has_mac = has_mac
             self.__msg_size = msg_size
             self.__inp = inp[offset:]
             self.__input_len = input_len - offset




More information about the Zope-Checkins mailing list