Fix an edge case with tls hello fragment

This commit is contained in:
yuhan6665 2024-04-04 02:50:15 -04:00
parent e64fb3ca9b
commit 548646fb06

View File

@ -373,6 +373,9 @@ func (f *FragmentWriter) Write(b []byte) (int, error) {
return f.writer.Write(b) return f.writer.Write(b)
} }
recordLen := 5 + ((int(b[3]) << 8) | int(b[4])) recordLen := 5 + ((int(b[3]) << 8) | int(b[4]))
if len(b) < recordLen { // maybe already fragmented somehow
return f.writer.Write(b)
}
data := b[5:recordLen] data := b[5:recordLen]
buf := make([]byte, 1024) buf := make([]byte, 1024)
for from := 0; ; { for from := 0; ; {