Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzz_http3serverreq: Fuzz stream shutdown #315

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions fuzz/fuzz_http3serverreq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ int send_data(nghttp3_conn *conn) {
}
}; // namespace

namespace {
int shutdown_streams(nghttp3_conn *conn,
FuzzedDataProvider &fuzzed_data_provider) {
for (; fuzzed_data_provider.ConsumeBool();) {
auto stream_id = fuzzed_data_provider.ConsumeIntegralInRange<int64_t>(
0, NGHTTP3_MAX_VARINT);

if (fuzzed_data_provider.ConsumeBool()) {
auto rv = nghttp3_conn_shutdown_stream_read(conn, stream_id);
if (rv != 0) {
return rv;
}
} else {
nghttp3_conn_shutdown_stream_write(conn, stream_id);
}
}

return 0;
}
}; // namespace

namespace {
int set_stream_priorities(nghttp3_conn *conn,
FuzzedDataProvider &fuzzed_data_provider) {
Expand Down Expand Up @@ -343,6 +364,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
}

if (shutdown_streams(conn, fuzzed_data_provider) != 0) {
goto fin;
}

if (!shutdown_started && fuzzed_data_provider.ConsumeBool()) {
shutdown_started = true;

Expand Down
Loading