Skip to content

Commit 5424183

Browse files
committed
address: add MaxEventQueryLimit validation
1 parent f070a7d commit 5424183

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

address/event.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const (
5757
// DefaultEventQueryLimit is the number of events returned
5858
// when no limit is provided.
5959
DefaultEventQueryLimit = 512
60+
61+
// MaxEventQueryLimit is the maximum number of events that can be
62+
// returned in a single query.
63+
MaxEventQueryLimit = 16384
6064
)
6165

6266
// EventQueryParams holds the set of query params for address events.

rpcserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,10 @@ func (r *rpcServer) AddrReceives(ctx context.Context,
22302230
if req.Limit < 0 {
22312231
return nil, fmt.Errorf("limit must be non-negative")
22322232
}
2233+
if req.Limit > address.MaxEventQueryLimit {
2234+
return nil, fmt.Errorf("limit must be less than %d",
2235+
address.MaxEventQueryLimit)
2236+
}
22332237

22342238
sqlQuery.Offset = req.Offset
22352239
sqlQuery.Limit = req.Limit

0 commit comments

Comments
 (0)