From 3928cbe30e0923aafbc2182d97250c46d4a4849e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 25 Jun 2016 14:20:15 +0930 Subject: [PATCH] daemon: fail connection if preimage isn't valid for shachain. This means they generated it wrong. Signed-off-by: Rusty Russell --- daemon/packets.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/packets.c b/daemon/packets.c index a16c1e104..df1ce1a5c 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -819,7 +819,8 @@ Pkt *accept_pkt_revocation(struct peer *peer, const Pkt *pkt) proto_to_sha256(r->revocation_preimage, ci->revocation_preimage); // save revocation preimages in shachain - shachain_add_hash(&peer->their_preimages, 0xFFFFFFFFFFFFFFFFL - ci->commit_num, ci->revocation_preimage); + if (!shachain_add_hash(&peer->their_preimages, 0xFFFFFFFFFFFFFFFFL - ci->commit_num, ci->revocation_preimage)) + return pkt_err(peer, "preimage not next in shachain"); /* Save next revocation hash. */ proto_to_sha256(r->next_revocation_hash,