From 2a42f4471a2207990280cc5003ef2ea375d1f09b Mon Sep 17 00:00:00 2001 From: Jin Liu Date: Wed, 17 Jul 2019 13:24:15 -0700 Subject: [PATCH] Remove builder's specific path from panic Also fix the index out of range caused panic --- core/corehttp/proxy.go | 2 +- mk/golang.mk | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/corehttp/proxy.go b/core/corehttp/proxy.go index 8b9420668..1c72eab92 100644 --- a/core/corehttp/proxy.go +++ b/core/corehttp/proxy.go @@ -65,7 +65,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { } split = strings.SplitN(path, "/", 7) - if split[3] != "x" || split[5] != "http" { + if len(split) < 7 || split[3] != "x" || split[5] != "http" { return nil, fmt.Errorf("Invalid request path '%s'", path) } diff --git a/mk/golang.mk b/mk/golang.mk index b4e92a0a3..f55103b5e 100644 --- a/mk/golang.mk +++ b/mk/golang.mk @@ -10,6 +10,9 @@ unexport GOFLAGS GOFLAGS ?= GOTFLAGS ?= +# Try to make building as reproducible as possible by stripping the go path. +GOFLAGS += -asmflags=all=-trimpath="$(GOPATH)" -gcflags=all=-trimpath="$(GOPATH)" + ifeq ($(tarball-is),1) GOFLAGS += -mod=vendor endif