Fix: handle parse socks5 udp address properly (#2220)
This commit is contained in:
parent
44a1ae08ef
commit
0c5be93e15
2 changed files with 6 additions and 0 deletions
|
@ -241,6 +241,9 @@ func ReadPacket(r io.Reader, payload []byte) (net.Addr, int, error) {
|
||||||
return nil, 0, errors.New("remote address invalid")
|
return nil, 0, errors.New("remote address invalid")
|
||||||
}
|
}
|
||||||
uAddr := addr.UDPAddr()
|
uAddr := addr.UDPAddr()
|
||||||
|
if uAddr == nil {
|
||||||
|
return nil, 0, errors.New("parse addr error")
|
||||||
|
}
|
||||||
|
|
||||||
length := len(payload)
|
length := len(payload)
|
||||||
if n-headLen < length {
|
if n-headLen < length {
|
||||||
|
|
|
@ -170,6 +170,9 @@ func ReadPacket(r io.Reader, payload []byte) (net.Addr, int, int, error) {
|
||||||
return nil, 0, 0, errors.New("read addr error")
|
return nil, 0, 0, errors.New("read addr error")
|
||||||
}
|
}
|
||||||
uAddr := addr.UDPAddr()
|
uAddr := addr.UDPAddr()
|
||||||
|
if uAddr == nil {
|
||||||
|
return nil, 0, 0, errors.New("parse addr error")
|
||||||
|
}
|
||||||
|
|
||||||
if _, err = io.ReadFull(r, payload[:2]); err != nil {
|
if _, err = io.ReadFull(r, payload[:2]); err != nil {
|
||||||
return nil, 0, 0, errors.New("read length error")
|
return nil, 0, 0, errors.New("read length error")
|
||||||
|
|
Loading…
Reference in a new issue