From 0ec83049017044107f8d7ddbede69cb3b10bb11e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 26 Aug 2019 19:41:57 +0930 Subject: [PATCH] gossipd: fix premature towire_reply_short_channel_ids_end if no node_announcement. Our "are we finished?" logic was wrong: it tested if there are no more node_announcements, but it's possible that there were no node_announcements for either end of the channel whose information we sent. This is actually quite unusual on the real network: looking at mainnet statis from last May, 4301 of 4337 nodes have node_announcements. However, with query flags it's much more likely, since they might not ask for node announcements at all. (Found by gossip protocol tests) Signed-off-by: Rusty Russell --- gossipd/gossipd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index b19a64a55..92ceffaa8 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1576,7 +1576,9 @@ static void maybe_create_next_scid_reply(struct peer *peer) peer->scid_query_nodes_idx = i; /* All finished? */ - if (peer->scid_queries && peer->scid_query_nodes_idx == num) { + if (peer->scid_queries + && peer->scid_query_idx == tal_count(peer->scid_queries) + && peer->scid_query_nodes_idx == num) { /* BOLT #7: * * - MUST follow these responses with