mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-20 22:50:53 +00:00
Socks: Fix buffer full panic when encoding large UDP packets (#5252)
Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
parent
2f1fabb318
commit
b16a5f03fe
1 changed files with 5 additions and 0 deletions
|
|
@ -353,6 +353,11 @@ func EncodeUDPPacket(request *protocol.RequestHeader, data []byte) (*buf.Buffer,
|
|||
b.Release()
|
||||
return nil, err
|
||||
}
|
||||
// if data is too large, return an empty buffer (drop too big data)
|
||||
if b.Available() < int32(len(data)) {
|
||||
b.Clear()
|
||||
return b, nil
|
||||
}
|
||||
common.Must2(b.Write(data))
|
||||
return b, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue