1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-30 05:06:45 -05:00

defensive fix for improper usage of buf.New().

This commit is contained in:
Darien Raymond 2018-03-28 14:40:51 +02:00
parent eeed65f826
commit 12181f527f
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ func ReadMetadata(reader io.Reader) (*FrameMetadata, error) {
return nil, newError("invalid metalen ", metaLen).AtError()
}
b := buf.New()
b := buf.NewSize(uint32(metaLen))
defer b.Release()
if err := b.Reset(buf.ReadFullFrom(reader, int(metaLen))); err != nil {

View File

@ -173,7 +173,7 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
}
if reader.Buffered() > 0 {
payload := buf.New()
payload := buf.NewSize(uint32(reader.Buffered()))
common.Must(payload.Reset(func(b []byte) (int, error) {
return reader.Read(b[:reader.Buffered()])
}))