From 1daa561d91077155481eba725b4ba59277b06413 Mon Sep 17 00:00:00 2001 From: TheKysek Date: Fri, 21 Oct 2016 20:09:19 +0200 Subject: [PATCH] Catch more malformed message exceptions --- src/connection.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/connection.py b/src/connection.py index c660a7f..639921f 100644 --- a/src/connection.py +++ b/src/connection.py @@ -215,7 +215,12 @@ class Connection(threading.Thread): self.buffer_receive = self.buffer_receive[self.next_message_size:] self.next_message_size = shared.header_length self.last_message_received = time.time() - self._process_message(m) + try: + self._process_message(m) + except ValueError as e: + self.status = 'disconnecting' + logging.warning('Received malformed message from {}:{}: {}'.format(self.host, self.port, e)) + break def _process_message(self, m): if m.command == b'version':