]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Gracefully handle TCP client disconnections
authorMichał Kępień <michal@isc.org>
Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 18 Mar 2025 15:28:18 +0000 (16:28 +0100)
Prevent premature client disconnections during reading from triggering
unhandled exceptions in TCP connection handling code.

bin/tests/system/isctest/asyncserver.py

index 211d1402218d1f49fe0ca1743ea9db6f3cf9d903..952cb797563400042af379dfc3ffffe78902b08c 100644 (file)
@@ -542,10 +542,14 @@ class AsyncDnsServer(AsyncServer):
         peer = Peer(peer_info[0], peer_info[1])
 
         wire_length_bytes = await reader.read(2)
+        if len(wire_length_bytes) < 2:
+            return
         (wire_length,) = struct.unpack("!H", wire_length_bytes)
         logging.debug("Receiving TCP message (%d octets)...", wire_length)
 
         wire = await reader.read(wire_length)
+        if len(wire) < wire_length:
+            return
         full_message = wire_length_bytes + wire
         logging.debug("Received complete TCP message: %s", full_message.hex())