about summary refs log tree commit diff
path: root/main.py
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-23 15:56:44 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-23 15:56:44 +0300
commitd8d3b42a6665c218b8214c18cce161a16bab0a7c (patch)
tree7b4d3cff388ab27ecbb95cb63fb29e1aac81b160 /main.py
parentabb678c3582aec27329bd3cc77daf88472e30f90 (diff)
downloadhttpy-d8d3b42a6665c218b8214c18cce161a16bab0a7c.tar.gz
httpy-d8d3b42a6665c218b8214c18cce161a16bab0a7c.zip
Check received message length to prevent infinite loop in _recv_request method
Diffstat (limited to 'main.py')
-rw-r--r--main.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/main.py b/main.py
index 46740e9..18772f3 100644
--- a/main.py
+++ b/main.py
@@ -135,7 +135,10 @@ class HTTPServer:
 
         buffer = bytearray()
         while not self.stop_event.is_set():
-            buffer += client.recv(self.buf_len)
+            msg = client.recv(self.buf_len)
+            if len(msg) == 0:
+                break
+            buffer += msg
             if buffer[-4:] == b'\r\n\r\n':
                 return Request.create(buffer)
         return None