diff --git a/worker/agent.go b/worker/agent.go index 3d5e941..3ac7f3b 100644 --- a/worker/agent.go +++ b/worker/agent.go @@ -79,6 +79,7 @@ func (a *agent) work() { } if inpack, l, err = decodeInPack(data); err != nil { a.worker.err(err) + leftdata = data continue } leftdata = nil diff --git a/worker/inpack.go b/worker/inpack.go index a460c10..50ff23a 100644 --- a/worker/inpack.go +++ b/worker/inpack.go @@ -91,6 +91,10 @@ func decodeInPack(data []byte) (inpack *inPack, l int, err error) { return } 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] if len(dt) != int(dl) { // length not equal err = fmt.Errorf("Invalid data: %V", data)