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

Skip to content
Commit 2ddb6301 authored by Bernie Innocenti's avatar Bernie Innocenti
Browse files

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
parent c484a71a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment