fix: Validate VLESS encryption padding

This commit is contained in:
Shtorm
2026-11-30 20:16:58 +03:00
parent defc9493eb
commit 07041e7768
2 changed files with 11 additions and 6 deletions
+7 -5
View File
@@ -248,7 +248,8 @@ func ParsePadding(padding string, paddingLens, paddingGaps *[][3]int) (err error
if padding == "" {
return
}
maxLen := 0
const maximumPaddingLength = 18 + 65535
remainingPaddingLength := maximumPaddingLength
for i, s := range strings.Split(padding, ".") {
x := strings.Split(s, "-")
if len(x) < 3 || x[0] == "" || x[1] == "" || x[2] == "" {
@@ -268,15 +269,16 @@ func ParsePadding(padding string, paddingLens, paddingGaps *[][3]int) (err error
return E.New("first padding length must not be smaller than 35")
}
if i%2 == 0 {
paddingLength := max(y[1], y[2])
if paddingLength > remainingPaddingLength {
return E.New("total padding length must not be larger than ", maximumPaddingLength)
}
remainingPaddingLength -= paddingLength
*paddingLens = append(*paddingLens, y)
maxLen += max(y[1], y[2])
} else {
*paddingGaps = append(*paddingGaps, y)
}
}
if maxLen > 18+65535 {
return E.New("total padding length must not be larger than 65553")
}
return
}