From 7b1544157f5264354575f7c667afea240f6eba3d Mon Sep 17 00:00:00 2001 From: defa sun Date: Mon, 14 May 2018 14:25:00 -0700 Subject: [PATCH] fix out of range index in headerIndex, github.com/buger/goreplay/issues/578 --- proto/proto.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proto/proto.go b/proto/proto.go index 2722527..9c5adfe 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -93,6 +93,11 @@ func headerIndex(payload []byte, name []byte) int { return i - len(name) } + // We are at the end + if i == len(payload) { + return -1 + } + if payload[i] != name[j] { break }