From 29139e9edaa5b0da69a4d07d1e955de62aea0e8e Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Fri, 10 Aug 2018 21:34:00 +0500 Subject: [PATCH] Fix prefixer panic when body is too small --- http_prettifier.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http_prettifier.go b/http_prettifier.go index 6f585c7..dcfebba 100644 --- a/http_prettifier.go +++ b/http_prettifier.go @@ -16,6 +16,11 @@ func prettifyHTTP(p []byte) []byte { body := p[headSize:] headersPos := proto.MIMEHeadersEndPos(body) + + if headersPos < 5 || headersPos > len(body) { + return p + } + headers := body[:headersPos] content := body[headersPos:]