[tor-commits] [flashproxy/master] Don't apply_mask when we don't need to.

dcf at torproject.org dcf at torproject.org
Mon Apr 9 04:08:43 UTC 2012


commit 0c99f3dd9fab26a421bf30d9224c0839b9d93b6c
Author: David Fifield <david at bamsoftware.com>
Date:   Sat Apr 7 04:36:50 2012 -0700

    Don't apply_mask when we don't need to.
---
 connector.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/connector.py b/connector.py
index 1689c33..9c725be 100755
--- a/connector.py
+++ b/connector.py
@@ -219,14 +219,17 @@ class WebSocketDecoder(object):
                 # "The server MUST close the connection upon receiving a frame
                 # that is not masked."
                 raise self.MaskingError("Got unmasked payload from client")
-            mask_key = "\x00\x00\x00\x00"
+            mask_key = None
 
         if payload_len > self.MAX_MESSAGE_LENGTH:
             raise ValueError("Refusing to buffer payload of %d bytes" % payload_len)
 
         if len(self.buf) < offset + payload_len:
             return None
-        payload = apply_mask(self.buf[offset:offset+payload_len], mask_key)
+        if mask_key:
+            payload = apply_mask(self.buf[offset:offset+payload_len], mask_key)
+        else:
+            payload = self.buf[offset:offset+payload_len]
         self.buf = self.buf[offset+payload_len:]
 
         frame = WebSocketFrame()





More information about the tor-commits mailing list