From 4f9825549e693c9f90bf6d29181bb73395024678 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:59:10 +0800 Subject: [PATCH 1/2] opt: check array length --- pkg/net/exchange/client.go | 8 +++++++- venus-component/libp2p/exchange/client/client.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/net/exchange/client.go b/pkg/net/exchange/client.go index ff6519584e..331edec97d 100644 --- a/pkg/net/exchange/client.go +++ b/pkg/net/exchange/client.go @@ -334,7 +334,13 @@ func (c *client) GetFullTipSet(ctx context.Context, peers []peer.ID, tsk types.T return nil, err } - return validRes.toFullTipSets()[0], nil + fullTipsets := validRes.toFullTipSets() + + if len(fullTipsets) == 0 { + return nil, fmt.Errorf("unexpectedly got no tipsets in exchange") + } + + return fullTipsets[0], nil // If `doRequest` didn't fail we are guaranteed to have at least // *one* tipset here, so it's safe to index directly. } diff --git a/venus-component/libp2p/exchange/client/client.go b/venus-component/libp2p/exchange/client/client.go index f56b9577db..9160abbafd 100644 --- a/venus-component/libp2p/exchange/client/client.go +++ b/venus-component/libp2p/exchange/client/client.go @@ -339,7 +339,13 @@ func (c *client) GetFullTipSet(ctx context.Context, peer peer.ID, tsk chain.TipS return nil, err } - return validRes.toFullTipSets()[0], nil + fullTipsets := validRes.toFullTipSets() + + if len(fullTipsets) == 0 { + return nil, fmt.Errorf("unexpectedly got no tipsets in exchange") + } + + return fullTipsets[0], nil // If `doRequest` didn't fail we are guaranteed to have at least // *one* tipset here, so it's safe to index directly. } From d181856f985b378377cbb0e469838675894d9409 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:02:19 +0800 Subject: [PATCH 2/2] chore: bump version to v1.14.3 --- CHANGELOG.md | 4 ++++ pkg/constants/version.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f179d6e5a0..4fe62c2273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # venus changelog +## v1.14.3 + +* fix: index too large may out of range [[#6258](https://github.com/filecoin-project/venus/pull/6258)] + ## v1.14.2 * fix: exchange: allow up to 10k messages per block diff --git a/pkg/constants/version.go b/pkg/constants/version.go index 420d352f42..4aae8946f5 100644 --- a/pkg/constants/version.go +++ b/pkg/constants/version.go @@ -5,7 +5,7 @@ import ( ) // BuildVersion is the local build version, set by build system -const BuildVersion = "1.14.2" +const BuildVersion = "1.14.3" var CurrentCommit string