1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

fix a buffer bug

This commit is contained in:
v2ray 2016-05-01 20:14:57 +02:00
parent a538de56de
commit c11ddace15

View File

@ -27,9 +27,14 @@ func (this *AuthChunkReader) Read() (*alloc.Buffer, error) {
}
length := serial.BytesLiteral(buffer.Value[:2]).Uint16Value()
if length == 4 { // Length of authentication bytes.
if length <= 4 { // Length of authentication bytes.
return nil, io.EOF
}
if length > 8*1024 {
buffer.Release()
buffer = alloc.NewLargeBuffer()
}
buffer.SliceBack(16)
if _, err := io.ReadFull(this.reader, buffer.Value[:length]); err != nil {
buffer.Release()
return nil, err