check the size of byte array, greater or lesser

This commit is contained in:
mikespook 2012-12-26 17:03:15 +08:00
parent d6c6bfe9f0
commit fee531f9c1

View File

@ -139,12 +139,14 @@ func (a *agent) read() (data []byte, err error) {
l := int(common.BytesToUint32([4]byte{data[start+8], l := int(common.BytesToUint32([4]byte{data[start+8],
data[start+9], data[start+10], data[start+11]})) data[start+9], data[start+10], data[start+11]}))
total := l + 12 total := l + 12
if total == tl { if total == tl { // data is what we want
return return
} else { } else if total < tl{ // data[:total] is what we want, data[total:] is the more
a.in <- data[total:] a.in <- data[total:]
data = data[:total] data = data[:total]
return return
} else { // ops!
break
} }
} else { } else {
start++ start++