From c8c47786dab86e4e5d7e98e8b952ba5d96bf49c8 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Fri, 8 May 2020 03:11:29 +0100 Subject: [PATCH] x/ibc: fix int overflow (#6171) x/ibc/07-tendermint/types/test_utils.go: Calculate and use machine-dependent maxInt instead of causing int overflow by passing math.MaxInt64. Closes: #6130 --- x/ibc/07-tendermint/types/test_utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/ibc/07-tendermint/types/test_utils.go b/x/ibc/07-tendermint/types/test_utils.go index 2a2491b14847..316a44ff7a5e 100644 --- a/x/ibc/07-tendermint/types/test_utils.go +++ b/x/ibc/07-tendermint/types/test_utils.go @@ -1,7 +1,6 @@ package types import ( - "math" "time" "github.com/tendermint/tendermint/crypto/tmhash" @@ -9,6 +8,8 @@ import ( "github.com/tendermint/tendermint/version" ) +const maxInt = int(^uint(0) >> 1) + // Copied unimported test functions from tmtypes to use them here func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.BlockID { return tmtypes.BlockID{ @@ -28,7 +29,7 @@ func CreateTestHeader(chainID string, height int64, timestamp time.Time, valSet ChainID: chainID, Height: height, Time: timestamp, - LastBlockID: MakeBlockID(make([]byte, tmhash.Size), math.MaxInt64, make([]byte, tmhash.Size)), + LastBlockID: MakeBlockID(make([]byte, tmhash.Size), maxInt, make([]byte, tmhash.Size)), LastCommitHash: tmhash.Sum([]byte("last_commit_hash")), DataHash: tmhash.Sum([]byte("data_hash")), ValidatorsHash: vsetHash,