From 3c3d7e2df4a93210d3f3871a693247f9382dfd1e Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 18 Oct 2019 13:23:39 +0200 Subject: [PATCH] connectd: Do not clobber the for-variable when resolving over DNS We were using `i` as index variable in two nested loops. This works as long as the DNS seed resolves to a single address, but will crash if the node has both an A as well as an AAAA entry, at which point we'll try to index the hostname without a matching entry. Signed-off-by: Christian Decker <@cdecker> --- connectd/connectd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connectd/connectd.c b/connectd/connectd.c index a54c16b01..f57171d8e 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1271,10 +1271,10 @@ static void add_seed_addrs(struct wireaddr_internal **addrs, new_addrs = wireaddr_from_hostname(tmpctx, hostnames[i], DEFAULT_PORT, NULL, broken_reply, NULL); if (new_addrs) { - for (size_t i = 0; i < tal_count(new_addrs); i++) { + for (size_t j = 0; j < tal_count(new_addrs); j++) { struct wireaddr_internal a; a.itype = ADDR_INTERNAL_WIREADDR; - a.u.wireaddr = new_addrs[i]; + a.u.wireaddr = new_addrs[j]; status_debug("Resolved %s to %s", hostnames[i], type_to_string(tmpctx, struct wireaddr, &a.u.wireaddr));