diff options
author | David Goulet <dgoulet@torproject.org> | 2020-07-09 13:33:52 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-09 13:33:52 -0400 |
commit | 7bc54ccba9b9a9ac2ee9f5c1ecccd1d13afbcdda (patch) | |
tree | 398423306a5a36397df3d2c0caeb10cdf94ebacc | |
parent | 46e34842619be7467e3cd062a2c7fbcd112b9cff (diff) | |
download | tor-7bc54ccba9b9a9ac2ee9f5c1ecccd1d13afbcdda.tar.gz tor-7bc54ccba9b9a9ac2ee9f5c1ecccd1d13afbcdda.zip |
addr: Static assert resolved address cache size
This will make sure that we always properly initialize the cache by the exact
size all the time.
Related to #40022
Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r-- | src/app/config/resolve_addr.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c index 9e7c23c881..fb5cb2ed6c 100644 --- a/src/app/config/resolve_addr.c +++ b/src/app/config/resolve_addr.c @@ -42,15 +42,17 @@ typedef enum { } fn_address_ret_t; /** Last resolved addresses. */ -static tor_addr_t last_resolved_addrs[IDX_SIZE] = +static tor_addr_t last_resolved_addrs[] = { TOR_ADDR_NULL, TOR_ADDR_NULL, TOR_ADDR_NULL }; +CTASSERT(ARRAY_LENGTH(last_resolved_addrs) == IDX_SIZE); /** Last suggested addresses. * * These addresses come from a NETINFO cell from a trusted relay (currently * only authorities). We only use those in last resort. */ -static tor_addr_t last_suggested_addrs[IDX_SIZE] = +static tor_addr_t last_suggested_addrs[] = { TOR_ADDR_NULL, TOR_ADDR_NULL, TOR_ADDR_NULL }; +CTASSERT(ARRAY_LENGTH(last_suggested_addrs) == IDX_SIZE); static inline int af_to_idx(const int family) @@ -422,7 +424,9 @@ resolved_addr_set_last(const tor_addr_t *addr, const char *method_used, const char *hostname_used) { /** Have we done a first resolve. This is used to control logging. */ - static bool have_resolved_once[IDX_SIZE] = { false, false, false }; + static bool have_resolved_once[] = { false, false, false }; + CTASSERT(ARRAY_LENGTH(have_resolved_once) == IDX_SIZE); + bool *done_one_resolve; bool have_hostname = false; tor_addr_t *last_resolved; |