discovery: return an error if ChannelUpdate has unknown flags

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-11 14:59:12 -08:00
parent 249e578130
commit 8c181b6f4e
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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