From 63fbaf7b4a33d5657cd3338b7ea91a173b9973fb Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 30 Mar 2018 11:50:40 +0200 Subject: [PATCH] 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. --- src/address_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.20.1