Skip to content

Commit 40a1d62

Browse files
committed
Fix reshaping buffer maybe too long in vision
1 parent 3aed155 commit 40a1d62

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

vless/constant.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ func reshapeBuffer(b []byte) []*buf.Buffer {
3232
if len(b) < bufferLimit {
3333
return []*buf.Buffer{buf.As(b)}
3434
}
35-
index := int32(bytes.LastIndex(b, tlsApplicationDataStart))
36-
if index <= 0 {
37-
index = 8192 / 2
35+
var buffers []*buf.Buffer
36+
for len(b) >= bufferLimit {
37+
index := int32(bytes.LastIndex(b, tlsApplicationDataStart))
38+
if index < 32 || index > bufferLimit {
39+
index = 8192 / 2
40+
}
41+
buffers = append(buffers, buf.As(b[:index]))
42+
b = b[index:]
3843
}
39-
return []*buf.Buffer{buf.As(b[:index]), buf.As(b[index:])}
44+
buffers = append(buffers, buf.As(b))
45+
return buffers
4046
}

0 commit comments

Comments
 (0)