From af3d980252234616a7f10112080016dc92e7c2dd Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 2 Jul 2024 18:57:42 +0400 Subject: [PATCH] fix: index out of bounds in parseHost --- server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 8407696..37b917f 100644 --- a/server.go +++ b/server.go @@ -113,15 +113,17 @@ func handler(ctx *fasthttp.RequestCtx) { func parseHost(host []byte, https bool) ([]byte, []byte) { idx := bytes.LastIndex(host, []byte(":")) - var port []byte + var resHost, port []byte if idx != -1 { + resHost = host[:idx] port = host[idx+1:] } else { + resHost = host if https { port = []byte("443") } else { port = []byte("80") } } - return host[:idx], port + return resHost, port }