caddyfile: Reject long heredoc markers (#6098)

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
Francis Lavoie 2024-02-11 13:30:14 -05:00 committed by GitHub
parent c78ebb3d6a
commit e7a534d0a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 10 deletions

View file

@ -16,6 +16,7 @@ package caddyfile
import (
"bytes"
"fmt"
"io"
"unicode"
@ -118,6 +119,10 @@ func Format(input []byte) []byte {
heredoc = heredocClosed
} else {
heredocMarker = append(heredocMarker, ch)
if len(heredocMarker) > 32 {
errorString := fmt.Sprintf("heredoc marker too long: <<%s", string(heredocMarker))
panic(errorString)
}
write(ch)
continue
}