Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: security report fix #206

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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