commit | 2ddb630136ae8199debc2faa3586ba80e7ad5100 | [log] [tgz] |
---|---|---|
author | Bernie Innocenti <codewiz@google.com> | Wed Jan 15 20:57:16 2020 +0900 |
committer | Bernie Innocenti <codewiz@google.com> | Wed Jan 22 16:30:09 2020 +0900 |
tree | 0fb4cf6d2a18c36e239fb05e0fb8a693066f18de | |
parent | c484a71a2cf3f514b99b8e89f70b2bce4067b4ca [diff] |
Fix harmless cache key bug in res_cache The resolver's cache is keyed by a hash of the query, excluding certain sections such as the query ID and a few others. However, a loop bug caused the entire packet to be hashed to the end after the first invocation of _dnsPacket_hashBytes() in _dnsPacket_hashQuery(). The bug predates the inclusion of this code in Bionic in 2009, and was likely harmless: since _dnsPacket_hashBytes() adjusts the cursor to the end of the packet, the subsequent calls to _dnsPacket_readInt16() fail, returning return -1, which causes the loops to execute 0 times. This whole oldschool code could use a good rewrite into safer C++ and, while we're at it, also switch to a proper hash function. For now, let's start with a conservative bugfix, so at least it behaves the way it reads. Test: cd packages/modules/DnsResolver && atest . Change-Id: I9368115bc16373fd64989f2a37f1dcd8f3e71b94
This code uses LOG(X) for logging. Log levels are VERBOSE,DEBUG,INFO,WARNING and ERROR. The default setting is WARNING and logs relate to WARNING and ERROR will be shown. If you want to enable the DEBUG level logs, using following command. adb shell service call dnsresolver 10 i32 1 VERBOSE 0 DEBUG 1 INFO 2 WARNING 3 ERROR 4 Verbose resolver logs could contain PII -- do NOT enable in production builds.