perf: Cap RANDOM_STRING_N to 8182 (#1193)

This commit is contained in:
TwiN
2025-08-11 09:36:55 -04:00
committed by GitHub
parent 3ebed01b4c
commit daf67dc1e6
2 changed files with 4 additions and 1 deletions

View File

@@ -344,6 +344,9 @@ func (e *Endpoint) getParsedBody() string {
if err == nil {
body = randRegex.ReplaceAllStringFunc(body, func(match string) string {
n, _ := strconv.Atoi(match[15 : len(match)-1])
if n > 8192 {
n = 8192 // Limit the length of the random string to 8192 bytes to avoid excessive memory usage
}
const availableCharacterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, n)
for i := range b {