diff --git a/CHANGELOG.md b/CHANGELOG.md index f2568415e5..6d22497203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ IMPROVEMENTS: BUG FIXES: +* server: Fixed a crash when POST-ing an empty body to the /v1/query endpoint. [[GH-3791](https://github.com/hashicorp/consul/issues/3791)] * ui: Added a URI escape around key/value keys so that it's not possible to create unexpected partial key names when entering characters like `?` inside a key. [[GH-3760](https://github.com/hashicorp/consul/issues/3760)] ## 1.0.2 (December 15, 2017) diff --git a/agent/prepared_query_endpoint.go b/agent/prepared_query_endpoint.go index 1d8ee7ba27..0be0ea3ed9 100644 --- a/agent/prepared_query_endpoint.go +++ b/agent/prepared_query_endpoint.go @@ -22,12 +22,10 @@ func (s *HTTPServer) preparedQueryCreate(resp http.ResponseWriter, req *http.Req } s.parseDC(req, &args.Datacenter) s.parseToken(req, &args.Token) - if req.ContentLength > 0 { - if err := decodeBody(req, &args.Query, nil); err != nil { - resp.WriteHeader(http.StatusBadRequest) - fmt.Fprintf(resp, "Request decode failed: %v", err) - return nil, nil - } + if err := decodeBody(req, &args.Query, nil); err != nil { + resp.WriteHeader(http.StatusBadRequest) + fmt.Fprintf(resp, "Request decode failed: %v", err) + return nil, nil } var reply string