From 952722a8cf71687d0b0e487d4f1cda9c08e8bf54 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 24 Feb 2017 16:22:56 +1030 Subject: [PATCH] lightningd/gossip: Fix return from gossip. We should check that the peer it says it's returning is under its control, we need to take back the peer fd, and use the correct conversion routine for the packet it sends us. Signed-off-by: Rusty Russell --- lightningd/gossip_control.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index d24eb3118..2dfe52b00 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -10,6 +10,7 @@ #include #include #include +#include static void gossip_finished(struct subdaemon *gossip, int status) { @@ -57,11 +58,16 @@ static void peer_nongossip(struct subdaemon *gossip, const u8 *msg, int fd) if (!peer) fatal("Gossip gave bad peerid %"PRIu64, unique_id); - log_debug(gossip->log, "Peer %s said %s", - type_to_string(msg, struct pubkey, peer->id), - gossip_status_wire_type_name(fromwire_peektype(inner))); + if (peer->owner != gossip) + fatal("Gossip gave bad peerid %"PRIu64" (owner %s)", + unique_id, peer->owner ? peer->owner->name : "(none)"); + + /* It returned the fd. */ + assert(peer->fd == -1); + peer->fd = fd; + peer_set_condition(peer, "Gossip ended up receipt of %s", - gossip_status_wire_type_name(fromwire_peektype(inner))); + wire_type_name(fromwire_peektype(inner))); /* FIXME: create new daemon to handle peer. */ }