From 9702cfbcb7f88312a56c0081fb7d720abe3f2f6d Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Tue, 20 Nov 2018 16:34:17 +0200 Subject: [PATCH] [server] Fix a escaped heap allocation --- .x-run | 8 ++++++++ sources/cmd/server.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.x-run b/.x-run index 92a47c7..a769fd1 100644 --- a/.x-run +++ b/.x-run @@ -53,6 +53,14 @@ exit -- 1 !! +<< go / build / server / release / analyze / escapes + "${X_RUN[@]}" ':: go / build / server / release / analyze' "${@}" \ + 2>&1 \ + | grep -F -e ' escapes ' \ + | LC_ALL=C sort -n -k 2,2 -t ':' + exit -- 0 +!! + << go / build / server / release / publish test "${#}" -eq 0 diff --git a/sources/cmd/server.go b/sources/cmd/server.go index a529c4a..f00df8d 100644 --- a/sources/cmd/server.go +++ b/sources/cmd/server.go @@ -94,7 +94,7 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () { return } else if bytes.HasPrefix (_path, []byte ("/__/errors/banners/")) { _code := _path[len ("/__/errors/banners/") :] - if _code, _error := strconv.Atoi (BytesToString (_code)); _error == nil { + if _code, _error := strconv.Atoi (BytesToString (*NoEscapeBytes (&_code))); _error == nil { _banner, _bannerFound := ErrorBannersData[uint (_code)] if (_code > 0) && _bannerFound { _server.ServeStatic (_context, http.StatusOK, _banner, ErrorBannerContentType, ErrorBannerContentEncoding, true)