mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
Improve error handling in packet reader - check error before processing
Only clear reserved bytes if read was successful (err == nil). This prevents processing invalid data when conn.Read() returns an error. Code review feedback addressed. Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
@@ -183,7 +183,8 @@ func (bind *netBindClient) connectTo(endpoint *netEndpoint) error {
|
||||
buf := make([]byte, maxPacketSize)
|
||||
n, err := conn.Read(buf)
|
||||
|
||||
if n > 3 {
|
||||
// Only process data if we successfully read something
|
||||
if err == nil && n > 3 {
|
||||
// Clear reserved bytes
|
||||
buf[1] = 0
|
||||
buf[2] = 0
|
||||
|
||||
Reference in New Issue
Block a user