fix: index out of bounds in parseHost
This commit is contained in:
parent
68a5f0d2e9
commit
af3d980252
1 changed files with 4 additions and 2 deletions
|
@ -113,15 +113,17 @@ func handler(ctx *fasthttp.RequestCtx) {
|
||||||
|
|
||||||
func parseHost(host []byte, https bool) ([]byte, []byte) {
|
func parseHost(host []byte, https bool) ([]byte, []byte) {
|
||||||
idx := bytes.LastIndex(host, []byte(":"))
|
idx := bytes.LastIndex(host, []byte(":"))
|
||||||
var port []byte
|
var resHost, port []byte
|
||||||
if idx != -1 {
|
if idx != -1 {
|
||||||
|
resHost = host[:idx]
|
||||||
port = host[idx+1:]
|
port = host[idx+1:]
|
||||||
} else {
|
} else {
|
||||||
|
resHost = host
|
||||||
if https {
|
if https {
|
||||||
port = []byte("443")
|
port = []byte("443")
|
||||||
} else {
|
} else {
|
||||||
port = []byte("80")
|
port = []byte("80")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return host[:idx], port
|
return resHost, port
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue