From 8c181b6f4eaa413e2452d7198cd174424313c7c4 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 11 Nov 2017 14:59:12 -0800 Subject: [PATCH] discovery: return an error if ChannelUpdate has unknown flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we fix an existing bug that could result in a panic if we received a ChannelUpdate message with an unknown set of flags. If the flag wasn’t set to zero or one, then the pubKey parameter would be still nil when we attempted to validate it, causing an error to occur. We remedy this by instead returning an error if the flags are unknown. In a future commit, we will properly handle the set of flags that indicates the channel should be disabled. --- discovery/gossiper.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 142c0a785..075cb995e 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -885,6 +885,12 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l pubKey = chanInfo.NodeKey1 case 1: pubKey = chanInfo.NodeKey2 + default: + rErr := errors.Errorf("unknown flags=%v for "+ + "short_chan_id=%v", msg.Flags, shortChanID) + log.Error(rErr) + nMsg.err <- rErr + return nil } // Validate the channel announcement with the expected public