Insure start and limit query params do not overflow limit

This commit is contained in:
Tobie Morgan Hitchcock 2017-11-16 20:44:20 +00:00
parent 878ddbbf09
commit d7469c30d5

View file

@ -29,6 +29,9 @@ import (
func limit(c *fibre.Context, i int64) int64 {
if s := c.Query("limit"); len(s) > 0 {
if x, err := strconv.ParseInt(s, 10, 64); err == nil {
if x > i {
return i
}
return x
}
}
@ -38,6 +41,9 @@ func limit(c *fibre.Context, i int64) int64 {
func start(c *fibre.Context, i int64) int64 {
if s := c.Query("start"); len(s) > 0 {
if x, err := strconv.ParseInt(s, 10, 64); err == nil {
if x < i {
return i
}
return x
}
}