mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-04 23:27:32 +02:00
Security: Use strconv.Atoi() for safe string to int conversions
This commit is contained in:
parent
37eec298d7
commit
056bef7d5e
@ -156,16 +156,13 @@ func getStartLimit(req *http.Request) (start int, limit int) {
|
|||||||
limit = 50
|
limit = 50
|
||||||
|
|
||||||
s := req.URL.Query().Get("start")
|
s := req.URL.Query().Get("start")
|
||||||
if n, e := strconv.ParseInt(s, 10, 64); e == nil && n > 0 {
|
if n, err := strconv.Atoi(s); err == nil && n > 0 {
|
||||||
start = int(n)
|
start = n
|
||||||
}
|
}
|
||||||
|
|
||||||
l := req.URL.Query().Get("limit")
|
l := req.URL.Query().Get("limit")
|
||||||
if n, e := strconv.ParseInt(l, 10, 64); e == nil && n > 0 {
|
if n, err := strconv.Atoi(l); err == nil && n > 0 {
|
||||||
if n > 500 {
|
limit = n
|
||||||
n = 500
|
|
||||||
}
|
|
||||||
limit = int(n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return start, limit
|
return start, limit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user