From 24e36852afaa24097e60735c0d6a34ff3492b14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 14 Jan 2020 16:51:33 +0100 Subject: [PATCH 1/2] Fix nil signature verification --- chain/types/blockheader.go | 4 ++++ chain/types/signature.go | 3 +++ chain/types/signature_cgo.go | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index c91d029fc..ff4c6467f 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -120,6 +120,10 @@ func (blk *BlockHeader) CheckBlockSignature(ctx context.Context, worker address. _, span := trace.StartSpan(ctx, "checkBlockSignature") defer span.End() + if blk.BlockSig == nil { + return xerrors.New("block signature not present") + } + sigb, err := blk.SigningBytes() if err != nil { return xerrors.Errorf("failed to get block signing bytes: %w", err) diff --git a/chain/types/signature.go b/chain/types/signature.go index f3a61327b..3b0862206 100644 --- a/chain/types/signature.go +++ b/chain/types/signature.go @@ -116,5 +116,8 @@ func (s *Signature) UnmarshalCBOR(br io.Reader) error { } func (s *Signature) Equals(o *Signature) bool { + if s == nil || o == nil { + return s == o + } return s.Type == o.Type && bytes.Equal(s.Data, o.Data) } diff --git a/chain/types/signature_cgo.go b/chain/types/signature_cgo.go index d86e41d72..a7423d946 100644 --- a/chain/types/signature_cgo.go +++ b/chain/types/signature_cgo.go @@ -9,9 +9,14 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-crypto" "github.com/minio/blake2b-simd" + "golang.org/x/xerrors" ) func (s *Signature) Verify(addr address.Address, msg []byte) error { + if s == nil { + return xerrors.Errorf("signature is nil") + } + if addr.Protocol() == address.ID { return fmt.Errorf("must resolve ID addresses before using them to verify a signature") } From 5e11da73163043ac4932435c54045efb4d5f3f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 14 Jan 2020 16:53:05 +0100 Subject: [PATCH 2/2] build: bump version --- build/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/version.go b/build/version.go index 01c209b1d..3ca9bda56 100644 --- a/build/version.go +++ b/build/version.go @@ -5,7 +5,7 @@ import "fmt" var CurrentCommit string // BuildVersion is the local build version, set by build system -const BuildVersion = "0.2.1" +const BuildVersion = "0.2.2" var UserVersion = BuildVersion + CurrentCommit