tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 66751503f3e072422368468251b91569d2f4dce1
parent 25595016f0522f4bd58259ad53c96023515ffa3a
Author: Nick Mathewson <nickm@torproject.org>
Date:   Mon, 15 Dec 2025 11:37:24 -0500

Fix a false positive from valgrind

When you have code that looks like this:
```
struct foo {
   unsigned a : 30;
   unsigned b : 2;
}

bool
check_foo(const struct foo *myfoo) {
   return myfoo->b == 1;
}

bool
check_b(int b) {
   struct foo myfoo;
   myfoo.b = b;
   return check_foo(&myfoo);
}
```

It seems that valgrind can complain because the CPU word containing
the fields a and b is not wholly initialized, and the instruction in
`check_foo` that reads `myfoo->b` loads that whole word.

Closes #41182.

Diffstat:
Achanges/bug41182 | 4++++
Msrc/feature/stats/geoip_stats.c | 1+
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/changes/bug41182 b/changes/bug41182 @@ -0,0 +1,4 @@ + o Minor bugfixes (tooling): + - Fix a false positive valgrind related to inspecting + a bitfield next to another uninitialized bitfield. + Fixes bug 41182; bugfix on 0.3.3.2-alpha. diff --git a/src/feature/stats/geoip_stats.c b/src/feature/stats/geoip_stats.c @@ -305,6 +305,7 @@ geoip_lookup_client(const tor_addr_t *addr, const char *transport_name, geoip_client_action_t action) { clientmap_entry_t lookup; + memset(&lookup, 0, sizeof(lookup)); tor_assert(addr);