packetLength can be negative

Fixes #359
This commit is contained in:
Frank Denis 2018-04-16 02:05:28 +02:00
parent 0cca203bb0
commit 5be294a6e2
1 changed files with 1 additions and 1 deletions

View File

@ -65,7 +65,7 @@ func ReadPrefixed(conn *net.TCPConn) ([]byte, error) {
return buf, errors.New("Packet too short")
}
}
if pos >= 2+packetLength {
if packetLength >= 0 && pos >= 2+packetLength {
return buf[2 : 2+packetLength], nil
}
}