Skip to content

Commit 9c2c4b6

Browse files
committed
fix: api: Length check the array sent to RPC
1 parent 0f2b03e commit 9c2c4b6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/submodule/eth/eth_api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
cbg "github.com/whyrusleeping/cbor-gen"
3737
)
3838

39+
const maxEthFeeHistoryRewardPercentiles = 100
40+
3941
var log = logging.Logger("eth_api")
4042

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

0 commit comments

Comments
 (0)