2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Gracefully handle invalid queries

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.

(cherry picked from commit fd0290c919)
This commit is contained in:
Michał Kępień
2025-04-11 09:14:57 -05:00
parent d86caaee15
commit f919aa7cbb

View 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)