From 785efcfaa21c49ee4bd06982b4217f30c57af2e5 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 5 Sep 2018 16:42:16 -0700 Subject: [PATCH] channeldb: also ignore the EOF error when trying to read ExtraOpaqueBytes In this commit, we account for the additional case wherein the announcement hasn't yet been written with the extra zero byte to indicate that there aren't any remaining bytes to be read. Before this commit, we accounted for the case where the announcement was written with the extra byte, but now we ensure that legacy nodes that upgrade will be able to boot properly. --- channeldb/graph.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/channeldb/graph.go b/channeldb/graph.go index 8f56d8ee..63f04bef 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -2860,7 +2860,10 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) { node.ExtraOpaqueData, err = wire.ReadVarBytes( r, 0, MaxAllowedExtraOpaqueBytes, "blob", ) - if err != nil && err != io.ErrUnexpectedEOF { + switch { + case err == io.ErrUnexpectedEOF: + case err == io.EOF: + case err != nil: return LightningNode{}, err } @@ -3012,7 +3015,10 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) { edgeInfo.ExtraOpaqueData, err = wire.ReadVarBytes( r, 0, MaxAllowedExtraOpaqueBytes, "blob", ) - if err != nil && err != io.ErrUnexpectedEOF { + switch { + case err == io.ErrUnexpectedEOF: + case err == io.EOF: + case err != nil: return ChannelEdgeInfo{}, err } @@ -3260,7 +3266,10 @@ func deserializeChanEdgePolicy(r io.Reader, edge.ExtraOpaqueData, err = wire.ReadVarBytes( r, 0, MaxAllowedExtraOpaqueBytes, "blob", ) - if err != nil && err != io.ErrUnexpectedEOF { + switch { + case err == io.ErrUnexpectedEOF: + case err == io.EOF: + case err != nil: return nil, err }