mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-20 21:16:22 +02:00
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>
This commit is contained in:
parent
46e3484261
commit
7bc54ccba9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user