diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-23 15:56:44 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-23 15:56:44 +0300 |
| commit | d8d3b42a6665c218b8214c18cce161a16bab0a7c (patch) | |
| tree | 7b4d3cff388ab27ecbb95cb63fb29e1aac81b160 | |
| parent | abb678c3582aec27329bd3cc77daf88472e30f90 (diff) | |
| download | httpy-d8d3b42a6665c218b8214c18cce161a16bab0a7c.tar.gz httpy-d8d3b42a6665c218b8214c18cce161a16bab0a7c.zip | |
Check received message length to prevent infinite loop in _recv_request method
| -rw-r--r-- | main.py | 5 |
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 |