fix: a huge export or list page answers an empty page instead of panicking (WR-14)

(page-1)*perPage overflowed for a large page and sliced out of range.
Export compares the page with the page count before multiplying, and the
list endpoints cap the page number.
This commit is contained in:
2026-10-27 15:33:21 +01:00
parent c2ba33ee94
commit 59c37a8fea
3 changed files with 22 additions and 4 deletions

View File

@@ -160,9 +160,11 @@ func (s *Service) Export(ctx context.Context, dataset, delimiter string, page, p
page = 1
}
out.Page = page
start := (page - 1) * perPage
if start > len(rows) {
start = len(rows)
// A page past the last is empty; compared before multiplying, so a
// huge page cannot overflow into a negative start (WR-14).
start := len(rows)
if page <= out.Pages {
start = (page - 1) * perPage
}
end := min(start+perPage, len(rows))
rows = rows[start:end]