From 762c795c9bcd9995fb9a709f24af42eb07381520 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 5 Oct 2018 12:49:09 -0700 Subject: [PATCH] gossip: reject channel_update with invalid `htlc_max_msat` If the channel update signals an invalid `htlc_maximum_msat` value, we ignore the update. --- gossipd/routing.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gossipd/routing.c b/gossipd/routing.c index 8bb3a97b7..1695744d5 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1084,6 +1084,16 @@ bool routing_add_channel_update(struct routing_state *rstate, if (!chan) return false; + if (message_flags & ROUTING_OPT_HTLC_MAX_MSAT) { + /* Reject update if the `htlc_maximum_msat` is greater + * than the total available channel satoshis */ + if (htlc_maximum_msat > chan->satoshis * 1000) + return false; + } else { + /* If not indicated, set htlc_max_msat to channel capacity */ + htlc_maximum_msat = chan->satoshis * 1000; + } + direction = channel_flags & 0x1; set_connection_values(chan, direction, fee_base_msat, fee_proportional_millionths, expiry,