Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3cc6e8a authored by chenbruce's avatar chenbruce
Browse files

[Resolver-log]: Refactor EDNS OPT log print.

An OPT RR has a fixed part and a variable set of options expressed
as {attribute, value} pairs. In OPTION-DATA print function, we
refactor the EDNS print part becuase it could not handle multi-pairs
data well. If the dns server sent two pairs, the print
funtion will have infinite loops.

Bug: 128284562
Test: make; flash; enable resolv log(VERBOSE);
Test: set private DNS to strict mode
Test: server = 1dot1dot1dot1.cloudflare-dns.com
Test: access www.hp.com to make sure issue doesn't happen.
Change-Id: I5ff30c933728f1a4034faeca42fce97a22551ea8
parent a32c8c1d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -185,8 +185,8 @@ static void do_section(ns_msg* handle, ns_sect section) {
            ttl = ns_rr_ttl(rr);
            dbprint(p, end, "; EDNS: version: %zu, udp=%u, flags=%04zx\n", (ttl >> 16) & 0xff,
                    ns_rr_class(rr), ttl & 0xffff);
            while (rdatalen >= 4) {
            const u_char* cp = ns_rr_rdata(rr);
            while (rdatalen <= ns_rr_rdlen(rr) && rdatalen >= 4) {
                int i;

                GETSHORT(optcode, cp);
@@ -223,6 +223,7 @@ static void do_section(ns_msg* handle, ns_sect section) {
                    }
                }
                rdatalen -= 4 + optlen;
                cp += optlen;
            }
        } else {
            n = ns_sprintrr(handle, &rr, NULL, NULL, buf, (u_int) buflen);