-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(query): clamp offset+limit to avoid uint64 overflow (Fixes #25006) #25049
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
b075a82
159156a
a622013
b44fc46
20c6c46
cfa1aed
973f0f4
1a35528
64b0ae7
5c8621e
c956701
69096b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -375,3 +375,17 @@ func (s *paginationTestSuite) TestPaginate() { | |
| // Output: | ||
| // balances:<denom:"foo0denom" amount:"100" > pagination:<next_key:"foo1denom" total:2 > | ||
| } | ||
|
|
||
| func (s *paginationTestSuite) TestClampOverflow() { | ||
| s.T().Log("verify that Limit is clamped when Offset+Limit would overflow") | ||
|
|
||
| pageReq := &query.PageRequest{ | ||
| Offset: uint64(5), | ||
| Limit: ^uint64(0), | ||
| } | ||
|
|
||
| clamped := query.ClampPageRequestLimit(pageReq) | ||
|
|
||
| want := query.PaginationMaxLimit - clamped.Offset | ||
| s.Require().Equal(want, clamped.Limit) | ||
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably prefer to keep this as a private function - no need to export