Skip to content

Commit

Permalink
fix msan (#8456)
Browse files Browse the repository at this point in the history
Sending an HTTP/1.1 request with an empty host to an Envoy with redirect configured causes a use-of-unitialized-value when processing the request host.
This was caught running msan in google.

Also fixes unneeded `const absl::string_view&` parameters

Risk level: Low

Signed-off-by: Asra Ali <[email protected]>
  • Loading branch information
asraa authored and lizan committed Oct 2, 2019
1 parent e279cc8 commit 5d5dda9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions source/common/router/config_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,14 @@ void RouteEntryImplBase::finalizePathHeader(Http::HeaderMap& headers,
}

absl::string_view RouteEntryImplBase::processRequestHost(const Http::HeaderMap& headers,
const absl::string_view& new_scheme,
const absl::string_view& new_port) const {
absl::string_view new_scheme,
absl::string_view new_port) const {

absl::string_view request_host = headers.Host()->value().getStringView();
size_t host_end;
if (request_host.empty()) {
return request_host;
}
// Detect if IPv6 URI
if (request_host[0] == '[') {
host_end = request_host.rfind("]:");
Expand Down
5 changes: 2 additions & 3 deletions source/common/router/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,8 @@ class RouteEntryImplBase : public RouteEntry,

// Router::DirectResponseEntry
std::string newPath(const Http::HeaderMap& headers) const override;
absl::string_view processRequestHost(const Http::HeaderMap& headers,
const absl::string_view& new_scheme,
const absl::string_view& new_port) const;
absl::string_view processRequestHost(const Http::HeaderMap& headers, absl::string_view new_scheme,
absl::string_view new_port) const;
void rewritePathHeader(Http::HeaderMap&, bool) const override {}
Http::Code responseCode() const override { return direct_response_code_.value(); }
const std::string& responseBody() const override { return direct_response_body_; }
Expand Down

0 comments on commit 5d5dda9

Please sign in to comment.