[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - smac.py:1.38.6.4

Christian Reis kiko at async.com.br
Thu Dec 18 21:14:55 EST 2003


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

Modified Files:
      Tag: Zope-2_7-branch
	smac.py 
Log Message:
Backport fix from HEAD: remember has_mac value across handle_read()
calls. Solved a problem where the MAC header wasn't read for messages
that were large enough to require multiple handle_read() calls.


=== ZODB3/ZEO/zrpc/smac.py 1.38.6.3 => 1.38.6.4 ===
--- ZODB3/ZEO/zrpc/smac.py:1.38.6.3	Fri Sep 19 15:47:56 2003
+++ ZODB3/ZEO/zrpc/smac.py	Thu Dec 18 21:14:54 2003
@@ -84,14 +84,18 @@
         self.__input_lock = threading.Lock()
         self.__inp = None # None, a single String, or a list
         self.__input_len = 0
-        # Instance variables __state and __msg_size work together:
+        # Instance variables __state, __msg_size and __has_mac work together:
         #   when __state == 0:
         #     __msg_size == 4, and the next thing read is a message size;
+        #     __has_mac is set according to the MAC_BIT in the header
         #   when __state == 1:
         #     __msg_size is variable, and the next thing read is a message.
+        #     __has_mac indicates if we're in MAC mode or not (and
+        #               therefore, if we need to check the mac header)
         # 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 +153,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 +176,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 +212,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 Zodb-checkins mailing list