]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: do not trigger assertions on invalid query
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 4 Jul 2022 02:44:46 +0000 (11:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 8 Jul 2022 20:20:10 +0000 (05:20 +0900)
src/resolve/resolved-dns-scope.c
src/resolve/resolved-mdns.c

index 4fbcd3d4495767a5b8616dc4402b0f05ea38184d..473e397013bb6c1f2fed696db828088cd25010a8 100644 (file)
@@ -1011,7 +1011,9 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
                 return;
         }
 
-        assert(dns_question_size(p->question) == 1);
+        if (dns_question_size(p->question) != 1)
+                return (void) log_debug("Received LLMNR query without question or multiple questions, ignoring.");
+
         key = dns_question_first_key(p->question);
 
         r = dns_zone_lookup(&s->zone, key, 0, &answer, &soa, &tentative);
index 2ad3a792da5f22efd321917606803cb7ef9dc89d..e1965c3833d80828771fa1bdecb85f2747ac0adb 100644 (file)
@@ -254,7 +254,8 @@ static int mdns_scope_process_query(DnsScope *s, DnsPacket *p) {
         if (r < 0)
                 return log_debug_errno(r, "Failed to extract resource records from incoming packet: %m");
 
-        assert_return((dns_question_size(p->question) > 0), -EINVAL);
+        if (dns_question_size(p->question) <= 0)
+                return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Received mDNS query without question, ignoring.");
 
         unicast_reply = mdns_should_reply_using_unicast(p);
         if (unicast_reply && !sender_on_local_subnet(s, p)) {