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

Commit ad12ba9c authored by Mike Yu's avatar Mike Yu
Browse files

Fix a bug in DoT probe

Fix the bug that passes wrong buffer to checkDnsResponse() in DoT
probe thread. Also fix a typo.

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1737424

Bug: 188153519
Test: run resolv_integration_test twice
Change-Id: I5ba4841f2130ab05cee95d573568540de7a95f86
Merged-In: I5ba4841f2130ab05cee95d573568540de7a95f86
parent 37de0d69
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -289,8 +289,7 @@ bool DnsTlsTransport::validate(const DnsTlsServer& server, uint32_t mark) {
        return false;
    }

    const std::vector<uint8_t>& recvbuf = r.response;
    if (auto result = checkDnsResponse(recvbuf); !result.ok()) {
    if (auto result = checkDnsResponse(r.response); !result.ok()) {
        LOG(WARNING) << "checkDnsResponse failed: " << result.error().message();
        return false;
    }
@@ -298,7 +297,7 @@ bool DnsTlsTransport::validate(const DnsTlsServer& server, uint32_t mark) {
    // If this validation is not for opportunistic mode, or the flags are not properly set,
    // the validation is done. If not, the validation will compare DoT probe latency and
    // UDP probe latency, and it will pass if:
    //   dot_probe_latency < latencyFactor * udp_probe_latency * latencyOffsetMs
    //   dot_probe_latency < latencyFactor * udp_probe_latency + latencyOffsetMs
    //
    // For instance, with latencyFactor = 3 and latencyOffsetMs = 10, if UDP probe latency is 5 ms,
    // DoT probe latency must less than 25 ms.
@@ -345,7 +344,7 @@ bool DnsTlsTransport::validate(const DnsTlsServer& server, uint32_t mark) {
        if (r.code != Response::success) {
            LOG(WARNING) << "query failed";
        } else {
            if (auto result = checkDnsResponse(recvbuf); !result.ok()) {
            if (auto result = checkDnsResponse(r.response); !result.ok()) {
                LOG(WARNING) << "checkDnsResponse failed: " << result.error().message();
            } else {
                dotProbeGotAnswer = true;