mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-08 13:29:53 +00:00
Merge pull request #760 from HynoR/master
fix: Fix slice out-of-bounds issues in ParseUDPMessage.
This commit is contained in:
commit
f854c38870
@ -212,6 +212,10 @@ func ParseUDPMessage(msg []byte) (*UDPMessage, error) {
|
|||||||
return nil, errors.ProtocolError{Message: "invalid address length"}
|
return nil, errors.ProtocolError{Message: "invalid address length"}
|
||||||
}
|
}
|
||||||
bs := buf.Bytes()
|
bs := buf.Bytes()
|
||||||
|
if len(bs) <= int(lAddr) {
|
||||||
|
// We use <= instead of < here as we expect at least one byte of data after the address
|
||||||
|
return nil, errors.ProtocolError{Message: "invalid message length"}
|
||||||
|
}
|
||||||
m.Addr = string(bs[:lAddr])
|
m.Addr = string(bs[:lAddr])
|
||||||
m.Data = bs[lAddr:]
|
m.Data = bs[lAddr:]
|
||||||
return m, nil
|
return m, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user