Skip to content

Commit

Permalink
http3: fix crash upon request without authority (#15799)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Zhang <[email protected]>
  • Loading branch information
danzh2010 authored Apr 2, 2021
1 parent f44686b commit ffe7bbd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/common/quic/envoy_quic_server_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void EnvoyQuicServerStream::OnInitialHeadersComplete(bool fin, size_t frame_len,
}
std::unique_ptr<Http::RequestHeaderMapImpl> headers =
quicHeadersToEnvoyHeaders<Http::RequestHeaderMapImpl>(header_list);
if (!Http::HeaderUtility::authorityIsValid(headers->Host()->value().getStringView())) {
if (Http::HeaderUtility::requestHeadersValid(*headers) != absl::nullopt) {
stream_delegate()->OnStreamError(quic::QUIC_HTTP_FRAME_ERROR, "Invalid headers");
return;
}
Expand Down
15 changes: 15 additions & 0 deletions test/integration/quic_http_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,21 @@ TEST_P(QuicHttpIntegrationTest, Reset101SwitchProtocolResponse) {
EXPECT_FALSE(response->complete());
}

TEST_P(QuicHttpIntegrationTest, ResetRequestWithoutAuthorityHeader) {
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
auto encoder_decoder = codec_client_->startRequest(Http::TestRequestHeaderMapImpl{
{":method", "GET"}, {":path", "/dynamo/url"}, {":scheme", "http"}});
request_encoder_ = &encoder_decoder.first;
auto response = std::move(encoder_decoder.second);

response->waitForEndStream();
codec_client_->close();
ASSERT_TRUE(response->complete());
EXPECT_EQ("400", response->headers().getStatusValue());
}

TEST_P(QuicHttpIntegrationTest, MultipleSetCookieAndCookieHeaders) {
initialize();

Expand Down

0 comments on commit ffe7bbd

Please sign in to comment.