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:
parent
eeed65f826
commit
12181f527f
@ -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 {
|
||||
|
@ -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()])
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user