fix: tweak

This commit is contained in:
Toby 2023-10-19 19:30:45 -07:00
parent d513ae115b
commit 131306b72b

View file

@ -212,8 +212,9 @@ func ParseUDPMessage(msg []byte) (*UDPMessage, error) {
return nil, errors.ProtocolError{Message: "invalid address length"}
}
bs := buf.Bytes()
if len(bs) < int(lAddr) {
return nil, errors.ProtocolError{Message: "message length mismatch"}
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.Data = bs[lAddr:]