Skip to content

Commit

Permalink
Merge pull request #6258 from filecoin-project/fix/index-too-large
Browse files Browse the repository at this point in the history
fix: index too large may out of range
  • Loading branch information
simlecode authored Jan 10, 2024
2 parents bc5ddbc + 00c1abe commit d18cba6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/net/exchange/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ func (c *client) validateCompressedIndices(chain []*exchange.BSTipSet) error {

for blockIdx := 0; blockIdx < blocksNum; blockIdx++ {
for _, mi := range msgs.BlsIncludes[blockIdx] {
if int(mi) >= len(msgs.Bls) {
if mi >= uint64(len(msgs.Bls)) {
return fmt.Errorf("index in BlsIncludes (%d) exceeds number of messages (%d)",
mi, len(msgs.Bls))
}
}

for _, mi := range msgs.SecpkIncludes[blockIdx] {
if int(mi) >= len(msgs.Secpk) {
if mi >= uint64(len(msgs.Secpk)) {
return fmt.Errorf("index in SecpkIncludes (%d) exceeds number of messages (%d)",
mi, len(msgs.Secpk))
}
Expand Down
4 changes: 2 additions & 2 deletions venus-component/libp2p/exchange/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,14 @@ func (c *client) validateCompressedIndices(chain []*exchange.BSTipSet) error {

for blockIdx := 0; blockIdx < blocksNum; blockIdx++ {
for _, mi := range msgs.BlsIncludes[blockIdx] {
if int(mi) >= len(msgs.Bls) {
if mi >= uint64(len(msgs.Bls)) {
return fmt.Errorf("index in BlsIncludes (%d) exceeds number of messages (%d)",
mi, len(msgs.Bls))
}
}

for _, mi := range msgs.SecpkIncludes[blockIdx] {
if int(mi) >= len(msgs.Secpk) {
if mi >= uint64(len(msgs.Secpk)) {
return fmt.Errorf("index in SecpkIncludes (%d) exceeds number of messages (%d)",
mi, len(msgs.Secpk))
}
Expand Down

0 comments on commit d18cba6

Please sign in to comment.