Fix short buffer

This commit is contained in:
H1JK 2023-02-24 21:19:57 +08:00
parent 9aacfe11e7
commit c5444a03ac

View File

@ -104,7 +104,12 @@ func (vc *Conn) ReadBuffer(buffer *buf.Buffer) error {
if vc.readFilterUUID { if vc.readFilterUUID {
headerUUIDLen = uuid.Size headerUUIDLen = uuid.Size
} }
header := buffer.FreeBytes()[:paddingHeaderLen+headerUUIDLen] var header []byte
if need := headerUUIDLen + paddingHeaderLen; buffer.FreeLen() < need {
header = make([]byte, need)
} else {
header = buffer.FreeBytes()[:need]
}
_, err := io.ReadFull(vc.ExtendedReader, header) _, err := io.ReadFull(vc.ExtendedReader, header)
if err != nil { if err != nil {
return err return err