Merge branch 'master' into 0.2-dev

This commit is contained in:
Xing Xing 2014-01-15 09:38:41 +08:00
commit 2bd19fb2fb
2 changed files with 5 additions and 0 deletions

View File

@ -79,6 +79,7 @@ func (a *agent) work() {
} }
if inpack, l, err = decodeInPack(data); err != nil { if inpack, l, err = decodeInPack(data); err != nil {
a.worker.err(err) a.worker.err(err)
leftdata = data
continue continue
} }
leftdata = nil leftdata = nil

View File

@ -91,6 +91,10 @@ func decodeInPack(data []byte) (inpack *inPack, l int, err error) {
return return
} }
dl := int(binary.BigEndian.Uint32(data[8:12])) dl := int(binary.BigEndian.Uint32(data[8:12]))
if len(data) < (dl + minPacketLength) {
err = fmt.Errorf("Not enough data: %V", data)
return
}
dt := data[minPacketLength : dl+minPacketLength] dt := data[minPacketLength : dl+minPacketLength]
if len(dt) != int(dl) { // length not equal if len(dt) != int(dl) { // length not equal
err = fmt.Errorf("Invalid data: %V", data) err = fmt.Errorf("Invalid data: %V", data)