Skip to content

Commit

Permalink
fix: security report fix (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
randyahx authored and unclezoro committed May 23, 2023
1 parent 89962f7 commit 32bf53a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func Paginate(numObjs, page, limit, defLimit int) (start, end int) {
start = (page - 1) * limit
end = limit + start

if end < start {
// check if this produces negative numbers, resulting in end < start
return -1, -1
}

if end >= numObjs {
end = numObjs
}
Expand Down
4 changes: 4 additions & 0 deletions x/authz/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (

// genGrant returns a slice of authorization grants.
func genGrant(r *rand.Rand, accounts []simtypes.Account, genT time.Time) []authz.GrantAuthorization {
// prevent errors if len < 1
if len(accounts) < 1 {
return make([]authz.GrantAuthorization, 0)
}
authorizations := make([]authz.GrantAuthorization, len(accounts)-1)
for i := 0; i < len(accounts)-1; i++ {
granter := accounts[i]
Expand Down
4 changes: 4 additions & 0 deletions x/feegrant/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (

// genFeeGrants returns a slice of randomly generated allowances.
func genFeeGrants(r *rand.Rand, accounts []simtypes.Account) []feegrant.Grant {
// prevent errors if len < 1
if len(accounts) < 1 {
return make([]feegrant.Grant, 0)
}
allowances := make([]feegrant.Grant, len(accounts)-1)
for i := 0; i < len(accounts)-1; i++ {
granter := accounts[i].Address
Expand Down
3 changes: 3 additions & 0 deletions x/nft/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

// genClasses returns a slice of nft class.
func genClasses(r *rand.Rand, accounts []simtypes.Account) []*nft.Class {
if len(accounts) < 1 {
return make([]*nft.Class, 0)
}
classes := make([]*nft.Class, len(accounts)-1)
for i := 0; i < len(accounts)-1; i++ {
classes[i] = &nft.Class{
Expand Down

0 comments on commit 32bf53a

Please sign in to comment.