Skip to content

Commit

Permalink
Tolerate bad mutate inputs in compatibility mode.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 697746529
  • Loading branch information
xinhaoyuan authored and copybara-github committed Nov 19, 2024
1 parent 7078295 commit f8195f5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fuzztest/internal/compatibility_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ std::string FuzzTestExternalEngineAdaptor::MutateData(absl::string_view data,
unsigned int seed) {
auto& impl = GetFuzzerImpl();
typename FuzzerImpl::PRNG prng(seed);
const auto input = [&]() -> decltype(impl.TryParse(data)) {
if (!IsEnginePlaceholderInput(data)) {
return impl.TryParse(data);
}
return impl.params_domain_.Init(prng);
}();
std::optional<GenericDomainCorpusType> input = std::nullopt;
if (!IsEnginePlaceholderInput(data)) {
auto parse_result = impl.TryParse(data);
if (parse_result.ok()) input = *std::move(parse_result);
}
if (!input) input = impl.params_domain_.Init(prng);
FUZZTEST_INTERNAL_CHECK(
input.has_value(),
"Both parsing and initiating the mutation input has failed.");
constexpr int kNumAttempts = 10;
std::string result;
for (int i = 0; i < kNumAttempts; ++i) {
Expand Down

0 comments on commit f8195f5

Please sign in to comment.