From: Guus Sliepen Date: Fri, 30 Mar 2018 09:50:40 +0000 (+0200) Subject: Prevent an infinite loop in get_recent_address(). X-Git-Tag: release-1.1pre16~6 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=63fbaf7b4a33d5657cd3338b7ea91a173b9973fb;p=tinc Prevent an infinite loop in get_recent_address(). When a node is offline, but we still have edges to it that have the same address as we already have in our address cache, an infinite loop would happen in get_recent_address(), because we forgot to advance the pointer in the list of known addresses, and kept looking at the same one over and over. Thanks to Sven-Haegar Koch for spotting the bug and providing diagnostics. --- diff --git a/src/address_cache.c b/src/address_cache.c index 2fa9baff..389615ea 100644 --- a/src/address_cache.c +++ b/src/address_cache.c @@ -129,12 +129,12 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) { if(cache->ai) { if(cache->aip) { sockaddr_t *sa = (sockaddr_t *)cache->aip->ai_addr; + cache->aip = cache->aip->ai_next; if(find_cached(cache, sa) != NOT_CACHED) { continue; } - cache->aip = cache->aip->ai_next; return sa; } else { free_known_addresses(cache->ai);