|
@@ -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 {
|