]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: synthesize empty name
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 Jan 2022 21:07:33 +0000 (06:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 Jan 2022 21:45:37 +0000 (06:45 +0900)
Do not return any error for empty name. Just returns empty answer.

Before:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 13617
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;. IN A

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 05:49:30 JST 2022
;; MSG SIZE  rcvd: 28
---

After:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7957
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;. IN A

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 06:05:02 JST 2022
;; MSG SIZE  rcvd: 28
---

Replaces #22197.

Fixes RHBZ#2039854 (https://bugzilla.redhat.com/show_bug.cgi?id=2039854).

src/resolve/resolved-dns-scope.c
src/resolve/resolved-dns-synthesize.c

index c0f6df6447c69fa9a53104514b04aa98ed4ff9ed..f0d0ca4bba31a63252d4ff2aa808638d2465f37e 100644 (file)
@@ -613,6 +613,10 @@ DnsScopeMatch dns_scope_good_domain(
         if ((SD_RESOLVED_FLAGS_MAKE(s->protocol, s->family, false, false) & flags) == 0)
                 return DNS_SCOPE_NO;
 
+        /* Never resolve empty name. */
+        if (dns_name_is_empty(domain))
+                return DNS_SCOPE_NO;
+
         /* Never resolve any loopback hostname or IP address via DNS, LLMNR or mDNS. Instead, always rely on
          * synthesized RRs for these. */
         if (is_localhost(domain) ||
index ef1423f44169521856dec0dd9d27f716f8ab0267..ea239e686d8d56a65e15f5b11e9baed0c930f02b 100644 (file)
@@ -394,7 +394,10 @@ int dns_synthesize_answer(
 
                 name = dns_resource_key_name(key);
 
-                if (is_localhost(name)) {
+                if (dns_name_is_empty(name)) {
+                        /* Do nothing. */
+
+                } else if (is_localhost(name)) {
 
                         r = synthesize_localhost_rr(m, key, ifindex, &answer);
                         if (r < 0)