From eccf3c2be1b591b005466377f5777341802dc4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 03:56:04 +0800 Subject: [PATCH] fix bug 250 --- lib/conn/conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/conn/conn.go b/lib/conn/conn.go index 8f19e6c..db03c40 100755 --- a/lib/conn/conn.go +++ b/lib/conn/conn.go @@ -87,7 +87,7 @@ func (s *Conn) GetShortContent(l int) (b []byte, err error) { //读取指定长度内容 func (s *Conn) ReadLen(cLen int, buf []byte) (int, error) { - if cLen > len(buf) { + if cLen > len(buf) || cLen <= 0 { return 0, errors.New("长度错误" + strconv.Itoa(cLen)) } if n, err := io.ReadFull(s, buf[:cLen]); err != nil || n != cLen {