From 143b1159402424b930881bc8d25c640f1d6cd581 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Wed, 5 May 2021 20:14:47 +0100 Subject: [PATCH] wip --- src/src/dns.c | 14 ++++++++++---- test/stderr/0277 | 8 ++++---- test/stderr/0469 | 2 +- test/stderr/2202 | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/src/dns.c b/src/src/dns.c index c68698786..217fe5f87 100644 --- a/src/src/dns.c +++ b/src/src/dns.c @@ -691,9 +691,11 @@ packet length has been lost inside libresolv, so we have to guess a replacement value. (The only way to fix this properly would be to re-implement res_search() and res_query() so that they don't muddle their success and packet length return values.) For added safety we only reset -the packet length if the packet header looks plausible. */ +the packet length if the packet header looks plausible. -static void +Return TRUE iff it seemed ok */ + +static BOOL fake_dnsa_len_for_fail(dns_answer * dnsa, int type) { const HEADER * h = (const HEADER *)dnsa->answer; @@ -710,7 +712,11 @@ if ( h->qr == 1 /* a response */ DEBUG(D_dns) debug_printf("faking res_search(%s) response length as %d\n", dns_text_type(type), (int)sizeof(dnsa->answer)); dnsa->answerlen = sizeof(dnsa->answer); + return TRUE; } +DEBUG(D_dns) debug_printf("DNS: couldn't fake dnsa len\n"); +/* Maybe we should just do a second lookup for an SOA? */ +return FALSE; } @@ -724,7 +730,7 @@ dns_expire_from_soa(dns_answer * dnsa, int type) { dns_scan dnss; -fake_dnsa_len_for_fail(dnsa, type); +if (!fake_dnsa_len_for_fail(dnsa, type)) return 0; for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_AUTHORITY); rr; rr = dns_next_rr(dnsa, &dnss, RESET_NEXT) @@ -1201,7 +1207,7 @@ switch (type) if (rc == DNS_NOMATCH) { - fake_dnsa_len_for_fail(dnsa, T_CSA); + if (!fake_dnsa_len_for_fail(dnsa, T_CSA)) return DNS_NOMATCH; for (rr = dns_next_rr(dnsa, &dnss, RESET_AUTHORITY); rr; rr = dns_next_rr(dnsa, &dnss, RESET_NEXT) diff --git a/test/stderr/0277 b/test/stderr/0277 index 1c81cc7ae..0cbd2a987 100644 --- a/test/stderr/0277 +++ b/test/stderr/0277 @@ -18,7 +18,7 @@ looking up host name for V4NET.2.3.4 DNS lookup of 4.3.2.V4NET.in-addr.arpa (PTR) using fakens DNS lookup of 4.3.2.V4NET.in-addr.arpa (PTR) gave HOST_NOT_FOUND returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for 4.3.2.V4NET.in-addr.arpa-PTR-xxxx, ttl -1 LOG: host_lookup_failed MAIN no host name found for IP address V4NET.2.3.4 @@ -96,7 +96,7 @@ looking up host name for V4NET.10.11.12 DNS lookup of 12.11.10.V4NET.in-addr.arpa (PTR) using fakens DNS lookup of 12.11.10.V4NET.in-addr.arpa (PTR) gave HOST_NOT_FOUND returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for 12.11.10.V4NET.in-addr.arpa-PTR-xxxx, ttl -1 LOG: host_lookup_failed MAIN no host name found for IP address V4NET.10.11.12 @@ -141,7 +141,7 @@ looking up host name for V4NET.1.1.1 DNS lookup of 1.1.1.V4NET.in-addr.arpa (PTR) using fakens DNS lookup of 1.1.1.V4NET.in-addr.arpa (PTR) gave HOST_NOT_FOUND returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for 1.1.1.V4NET.in-addr.arpa-PTR-xxxx, ttl -1 LOG: host_lookup_failed MAIN no host name found for IP address V4NET.1.1.1 @@ -186,7 +186,7 @@ looking up host name for V4NET.2.2.2 DNS lookup of 2.2.2.V4NET.in-addr.arpa (PTR) using fakens DNS lookup of 2.2.2.V4NET.in-addr.arpa (PTR) gave HOST_NOT_FOUND returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for 2.2.2.V4NET.in-addr.arpa-PTR-xxxx, ttl -1 LOG: host_lookup_failed MAIN no host name found for IP address V4NET.2.2.2 diff --git a/test/stderr/0469 b/test/stderr/0469 index 3401dedff..f3b559327 100644 --- a/test/stderr/0469 +++ b/test/stderr/0469 @@ -24,7 +24,7 @@ DNS lookup of mxt1c.test.ex (MX) succeeded DNS lookup of dontqualify (A) using fakens DNS lookup of dontqualify (A) gave NO_DATA returning DNS_NODATA -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for dontqualify-A-xxxx, ttl -1 fully qualified name = mxt1c.test.ex host_find_bydns yield = HOST_FIND_FAILED (0); returned hosts: diff --git a/test/stderr/2202 b/test/stderr/2202 index e936b5e6b..a7c78ea3a 100644 --- a/test/stderr/2202 +++ b/test/stderr/2202 @@ -42,7 +42,7 @@ DNS lookup of cioce.test.again.dns (MX) using fakens DNS lookup of cioce.test.again.dns (MX) gave TRY_AGAIN cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*") cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for cioce.test.again.dns-MX-xxxx, ttl -1 creating new cache entry lookup failed @@ -65,7 +65,7 @@ DNS lookup of cioce.test.again.dns (A) using fakens DNS lookup of cioce.test.again.dns (A) gave TRY_AGAIN cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*") cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH -DNS: no SOA record found for neg-TTL +DNS: couldn't fake dnsa len writing neg-cache entry for cioce.test.again.dns-A-xxxx, ttl -1 host_fake_gethostbyname(af=inet) returned 1 (HOST_NOT_FOUND) no IP address found for host cioce.test.again.dns (during SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4]) -- 2.30.2