1
0
mirror of https://gitlab.isc.org/isc-projects/bind9.git synced 2025-04-18 09:44:09 +03: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.
This commit is contained in:
Michał Kępień 2025-04-11 09:14:57 -05:00
parent 715bd1b667
commit fd0290c919
No known key found for this signature in database

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)