From 2a68a984c30034581c147d138d8a8fe6a418de24 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 15 Dec 2016 11:42:24 +1030 Subject: [PATCH] peer: fix unassigned error packet on receiving non-ASCII error. Reported-by: Lucas Betschart Signed-off-by: Rusty Russell --- daemon/peer.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/daemon/peer.c b/daemon/peer.c index 12f005c22..b924b1771 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -478,6 +478,15 @@ static bool peer_received_unexpected_pkt(struct peer *peer, const Pkt *pkt, goto out; } + /* BOLT #2: + * + * A node MUST fail the connection if it receives an `err` + * message, and MUST NOT send an `err` message in this case. + * For other connection failures, a node SHOULD send an + * informative `err` message. + */ + err = NULL; + /* Check packet for weird chars. */ for (p = pkt->error->problem; *p; p++) { if (cisprint(*p)) @@ -491,14 +500,6 @@ static bool peer_received_unexpected_pkt(struct peer *peer, const Pkt *pkt, } log_unusual(peer->log, "Error pkt '%s'", pkt->error->problem); - /* BOLT #2: - * - * A node MUST fail the connection if it receives an `err` - * message, and MUST NOT send an `err` message in this case. - * For other connection failures, a node SHOULD send an - * informative `err` message. - */ - err = NULL; out: return peer_comms_err(peer, err); }