mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-22 12:43:58 +08:00
Reject absurdly long duration strings (fix #4175)
This commit is contained in:
parent
49b7a25264
commit
f1f7a22674
6
caddy.go
6
caddy.go
|
@ -763,8 +763,12 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
// ParseDuration parses a duration string, adding
|
// ParseDuration parses a duration string, adding
|
||||||
// support for the "d" unit meaning number of days,
|
// support for the "d" unit meaning number of days,
|
||||||
// where a day is assumed to be 24h.
|
// where a day is assumed to be 24h. The maximum
|
||||||
|
// input string length is 1024.
|
||||||
func ParseDuration(s string) (time.Duration, error) {
|
func ParseDuration(s string) (time.Duration, error) {
|
||||||
|
if len(s) > 1024 {
|
||||||
|
return 0, fmt.Errorf("parsing duration: input string too long")
|
||||||
|
}
|
||||||
var inNumber bool
|
var inNumber bool
|
||||||
var numStart int
|
var numStart int
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user