]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Gracefully handle invalid queries
authorMichał Kępień <michal@isc.org>
Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)
committerMichał Kępień <michal@isc.org>
Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)
Prevent custom servers based on asyncserver.py from exiting prematurely
due to unhandled exceptions raised as a result of attempting to parse
invalid queries sent by clients.

bin/tests/system/isctest/asyncserver.py

index 33ca5ad6911036691d7bb9b69d0be31c4000a289..fb5f2c21c34da50ca3dd178f658c4b00948583de 100644 (file)
@@ -728,7 +728,11 @@ class AsyncDnsServer(AsyncServer):
         """
         Yield wire data to send as a response over the established transport.
         """
-        query = dns.message.from_wire(wire)
+        try:
+            query = dns.message.from_wire(wire)
+        except dns.exception.DNSException as exc:
+            logging.error("Invalid query from %s (%s): %s", peer, wire.hex(), exc)
+            return
         response_stub = dns.message.make_response(query)
         qctx = QueryContext(query, response_stub, peer, protocol)
         self._log_query(qctx, peer, protocol)