Skip to content

Commit

Permalink
fuzz: fix H2 codec fuzzer post envoyproxy#4262.
Browse files Browse the repository at this point in the history
In envoyproxy#4262, an ASSERT was added to guarantee that we wouldn't violate the
codec response contract regarding :status. This needed a corresponding
change in the H2 codec fuzzer.

Risk level: Low
Testing: Corpus entry added.

Signed-off-by: Harvey Tuch <htuch@google.com>
  • Loading branch information
htuch committed Aug 30, 2018
1 parent 01aa3f8 commit 5fa0fc2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
actions {
new_stream {
}
}
actions {
mutate {
buffer: 2
offset: 2
value: 2
}
}
actions {
client_drain {
}
}
actions {
stream_action {
response {
headers {
}
}
}
}
7 changes: 6 additions & 1 deletion test/common/http/http2/codec_impl_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class Stream : public LinkedObject<Stream> {
void directionalAction(DirectionalState& state,
const test::common::http::http2::DirectionalAction& directional_action) {
const bool end_stream = directional_action.end_stream();
const bool response = &state == &response_;
switch (directional_action.directional_action_selector_case()) {
case test::common::http::http2::DirectionalAction::kContinueHeaders: {
if (state.stream_state_ == StreamState::PendingHeaders) {
Expand All @@ -116,7 +117,11 @@ class Stream : public LinkedObject<Stream> {
}
case test::common::http::http2::DirectionalAction::kHeaders: {
if (state.stream_state_ == StreamState::PendingHeaders) {
state.encoder_->encodeHeaders(Fuzz::fromHeaders(directional_action.headers()), end_stream);
auto headers = Fuzz::fromHeaders(directional_action.headers());
if (response && headers.Status() == nullptr) {
headers.setReferenceKey(Headers::get().Status, "200");
}
state.encoder_->encodeHeaders(headers, end_stream);
state.stream_state_ = end_stream ? StreamState::Closed : StreamState::PendingDataOrTrailers;
}
break;
Expand Down

0 comments on commit 5fa0fc2

Please sign in to comment.