刘河 5 éve
szülő
commit
eccf3c2be1
1 módosított fájl, 1 hozzáadás és 1 törlés
  1. 1 1
      lib/conn/conn.go

+ 1 - 1
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 {