mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
connectd: correct a segfault in add_seed_addrs
lightning_connectd: FATAL SIGNAL 6 (version v0.6.1-1964-g226e2ae-modded) 0x5610a4a41b5d send_backtrace common/daemon.c:40 0x5610a4a41c03 crashdump common/daemon.c:53 0x7ff6bf71e83f ??? ???:0 0x7ff6bf71e7bb ??? ???:0 0x7ff6bf709534 ??? ???:0 0x5610a4a7a169 call_error ccan/ccan/tal/tal.c:93 0x5610a4a7a331 check_bounds ccan/ccan/tal/tal.c:165 0x5610a4a7a38f to_tal_hdr ccan/ccan/tal/tal.c:176 0x5610a4a7a3f1 to_tal_hdr_or_null ccan/ccan/tal/tal.c:186 0x5610a4a7b2d9 tal_bytelen ccan/ccan/tal/tal.c:632 0x5610a4a3a238 add_seed_addrs connectd/connectd.c:1282 0x5610a4a3a85c try_connect_peer connectd/connectd.c:1374 0x5610a4a3aaa2 connect_to_peer connectd/connectd.c:1419
This commit is contained in:
@@ -300,7 +300,6 @@ bool wireaddr_from_hostname(struct wireaddr **addrs, const char *hostname,
|
||||
struct addrinfo hints;
|
||||
int gai_err;
|
||||
bool res = false;
|
||||
struct wireaddr *addr;
|
||||
|
||||
if (no_dns)
|
||||
*no_dns = false;
|
||||
@@ -352,17 +351,17 @@ bool wireaddr_from_hostname(struct wireaddr **addrs, const char *hostname,
|
||||
}
|
||||
|
||||
for (addrinfo = addrinfos; addrinfo; addrinfo = addrinfo->ai_next) {
|
||||
addr = tal(addrs, struct wireaddr);
|
||||
struct wireaddr addr;
|
||||
if (addrinfo->ai_family == AF_INET) {
|
||||
sa4 = (struct sockaddr_in *) addrinfo->ai_addr;
|
||||
wireaddr_from_ipv4(addr, &sa4->sin_addr, port);
|
||||
wireaddr_from_ipv4(&addr, &sa4->sin_addr, port);
|
||||
res = true;
|
||||
} else if (addrinfo->ai_family == AF_INET6) {
|
||||
sa6 = (struct sockaddr_in6 *) addrinfo->ai_addr;
|
||||
wireaddr_from_ipv6(addr, &sa6->sin6_addr, port);
|
||||
wireaddr_from_ipv6(&addr, &sa6->sin6_addr, port);
|
||||
res = true;
|
||||
}
|
||||
tal_arr_expand(&addrs, addr);
|
||||
tal_arr_expand(addrs, addr);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
@@ -1267,22 +1267,22 @@ static void add_seed_addrs(struct wireaddr_internal **addrs,
|
||||
const struct node_id *id,
|
||||
struct sockaddr *broken_reply)
|
||||
{
|
||||
struct wireaddr **new_addrs;
|
||||
struct wireaddr *new_addrs;
|
||||
const char **hostnames;
|
||||
|
||||
new_addrs = tal_arr(tmpctx, struct wireaddr *, 0);
|
||||
new_addrs = tal_arr(tmpctx, struct wireaddr, 0);
|
||||
hostnames = seednames(tmpctx, id);
|
||||
|
||||
for (size_t i = 0; i < tal_count(hostnames); i++) {
|
||||
status_debug("Resolving %s", hostnames[i]);
|
||||
if (!wireaddr_from_hostname(new_addrs, hostnames[i], DEFAULT_PORT, NULL,
|
||||
if (!wireaddr_from_hostname(&new_addrs, hostnames[i], DEFAULT_PORT, NULL,
|
||||
broken_reply, NULL)) {
|
||||
status_debug("Could not resolve %s", hostnames[i]);
|
||||
} else {
|
||||
for (size_t i = 0; i < tal_count(new_addrs); i++) {
|
||||
struct wireaddr_internal a;
|
||||
a.itype = ADDR_INTERNAL_WIREADDR;
|
||||
a.u.wireaddr = *new_addrs[i];
|
||||
a.u.wireaddr = new_addrs[i];
|
||||
status_debug("Resolved %s to %s", hostnames[i],
|
||||
type_to_string(tmpctx, struct wireaddr,
|
||||
&a.u.wireaddr));
|
||||
@@ -1368,7 +1368,7 @@ static void try_connect_peer(struct daemon *daemon,
|
||||
}
|
||||
} else if (daemon->use_dns) {
|
||||
add_seed_addrs(&addrs, id,
|
||||
daemon->broken_resolver_response);
|
||||
daemon->broken_resolver_response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user