Skip to content

Commit

Permalink
Merge pull request #6293 from filecoin-project/fix/check-length
Browse files Browse the repository at this point in the history
fix: api: Length check the array sent to RPC
  • Loading branch information
LinZexiao authored Mar 14, 2024
2 parents 36d48cd + 9c2c4b6 commit 1aea0c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
)

const maxEthFeeHistoryRewardPercentiles = 100

var log = logging.Logger("eth_api")

var ErrNullRound = errors.New("requested epoch was a null round")
Expand Down Expand Up @@ -665,6 +667,9 @@ func (a *ethAPI) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (types.
}
rewardPercentiles := make([]float64, 0)
if params.RewardPercentiles != nil {
if len(*params.RewardPercentiles) > maxEthFeeHistoryRewardPercentiles {
return types.EthFeeHistory{}, errors.New("length of the reward percentile array cannot be greater than 100")
}
rewardPercentiles = append(rewardPercentiles, *params.RewardPercentiles...)
}
for i, rp := range rewardPercentiles {
Expand Down

0 comments on commit 1aea0c5

Please sign in to comment.