From e6c58fdc085f8875361563551699bcf02e3ede8b Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 15 Sep 2022 14:12:53 -0600 Subject: caddyfile: Prevent infinite nesting on fmt (fix #4175) --- caddyconfig/caddyfile/formatter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'caddyconfig') diff --git a/caddyconfig/caddyfile/formatter.go b/caddyconfig/caddyfile/formatter.go index cb0033f..3981cd6 100644 --- a/caddyconfig/caddyfile/formatter.go +++ b/caddyconfig/caddyfile/formatter.go @@ -153,7 +153,10 @@ func Format(input []byte) []byte { openBraceWritten = true nextLine() newLines = 0 - nesting++ + // prevent infinite nesting from ridiculous inputs (issue #4175) + if nesting < 10 { + nesting++ + } } switch { -- cgit v1.2.3