[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Don't crash when the Upgrade or Connection headers are missing.



commit 508079f995abdc054ca153d8ae109f80bc6e344d
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Fri Sep 7 05:05:14 2012 -0700

    Don't crash when the Upgrade or Connection headers are missing.
---
 flashproxy-client |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/flashproxy-client b/flashproxy-client
index daf710b..dfe060f 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -485,13 +485,21 @@ def handle_websocket_request(fd):
 
     # 3. An |Upgrade| header field containing the value "websocket", treated as
     # an ASCII case-insensitive value.
-    if "websocket" not in [x.strip().lower() for x in headers.get("upgrade").split(",")]:
+    upgrade = headers.get("upgrade")
+    if upgrade is None:
+        handler.send_error(400)
+        return None
+    if "websocket" not in [x.strip().lower() for x in upgrade.split(",")]:
         handler.send_error(400)
         return None
 
     # 4. A |Connection| header field that includes the token "Upgrade", treated
     # as an ASCII case-insensitive value.
-    if "upgrade" not in [x.strip().lower() for x in headers.get("connection").split(",")]:
+    connection = headers.get("connection")
+    if connection is None:
+        handler.send_error(400)
+        return None
+    if "upgrade" not in [x.strip().lower() for x in connection.split(",")]:
         handler.send_error(400)
         return None
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits