From 8f190c673c1589aa3a86da91f4a0303a3a27c8b4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 24 May 2017 19:40:06 +0930 Subject: [PATCH] channel: don't send disable update to gossipd if we haven't announced channel yet. Valgrind error file: /tmp/lightning-8k06jbb3/test_disconnect/lightning-7/valgrind-errors ==32307== Uninitialised byte(s) found during client check request ==32307== at 0x11EBAD: memcheck_ (mem.h:247) ==32307== by 0x11EC18: towire (towire.c:14) ==32307== by 0x11EF19: towire_short_channel_id (towire.c:92) ==32307== by 0x12203E: towire_channel_update (gen_peer_wire.c:918) ==32307== by 0x1148D4: send_channel_update (channel.c:185) ==32307== by 0x1175C5: peer_conn_broken (channel.c:1010) ==32307== by 0x13186F: destroy_conn (poll.c:173) ==32307== by 0x13188F: destroy_conn_close_fd (poll.c:179) ==32307== by 0x13B279: notify (tal.c:235) ==32307== by 0x13B721: del_tree (tal.c:395) ==32307== by 0x13BB3A: tal_free (tal.c:504) ==32307== by 0x130522: io_close (io.c:415) ==32307== Address 0xffefff87d is on thread 1's stack ==32307== in frame #2, created by towire_short_channel_id (towire.c:88) Signed-off-by: Rusty Russell --- lightningd/channel/channel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index e00237d61..862e66295 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -1007,9 +1007,13 @@ static struct io_plan *setup_peer_conn(struct io_conn *conn, struct peer *peer) static void peer_conn_broken(struct io_conn *conn, struct peer *peer) { - send_channel_update(peer, true); - /* Make sure gossipd actually gets this message before dying */ - daemon_conn_sync_flush(&peer->gossip_client); + /* If we have signatures, send an update to say we're disabled. */ + if (peer->have_sigs[LOCAL] && peer->have_sigs[REMOTE]) { + send_channel_update(peer, true); + + /* Make sure gossipd actually gets this message before dying */ + daemon_conn_sync_flush(&peer->gossip_client); + } status_failed(WIRE_CHANNEL_PEER_READ_FAILED, "peer connection broken: %s", strerror(errno)); }