From f6c99c60c39c875012503a8d5d6957f5296a06a7 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 14 Jun 2020 22:07:45 +0200 Subject: [PATCH] test --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 86198b8..c69ba9b 100644 --- a/main.go +++ b/main.go @@ -32,15 +32,20 @@ func main() { b, err = conn.ReadByte() logErrorDebug(err, "conn.ReadByte") p.PType = uint8(b) + if p.PLength <= 3 { + logInfoAlert("Wrong packet length") + break + } d := make([]byte, p.PLength-3) for { _, err := conn.Read(d[len(d):]) logErrorDebug(err, "conn.Read") - if len(d) == p.PLength-3 { + if len(d) == int(p.PLength-3) { break } } logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType) + } }