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

fix(replayer): replay corpus files in hidden dirs #254

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/oss_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fuzz-seconds: 60
dry-run: false
- name: Upload crashes
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand All @@ -66,7 +66,7 @@ jobs:
fuzz-seconds: 60
dry-run: false
- name: Upload crashes
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
5 changes: 3 additions & 2 deletions fuzzing/replay/file_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ absl::Status TraverseDirectory(
}
break;
}
if (absl::StartsWith(entry->d_name, ".")) {
auto entry_name = absl::string_view(entry->d_name);
if (entry_name == "." || entry_name == "..") {
continue;
}
const std::string entry_path = absl::StrCat(path, "/", entry->d_name);
const std::string entry_path = absl::StrCat(path, "/", entry_name);
status.Update(YieldFiles(entry_path, callback));
}
closedir(dir);
Expand Down
16 changes: 16 additions & 0 deletions fuzzing/replay/file_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ TEST(YieldFilesTest, YieldsDeepFiles) {
EXPECT_THAT(collected_paths, testing::SizeIs(4));
}

TEST(YieldFilesTest, YieldsHiddenFilesAndDirs) {
const std::string root_dir =
absl::StrCat(getenv("TEST_TMPDIR"), "/dir-with-hidden");
ASSERT_EQ(mkdir(root_dir.c_str(), 0755), 0);
ASSERT_TRUE(SetFileContents(absl::StrCat(root_dir, "/.a"), "foo").ok());
const std::string child_dir = absl::StrCat(root_dir, "/.hidden");
ASSERT_EQ(mkdir(child_dir.c_str(), 0755), 0);
ASSERT_TRUE(SetFileContents(absl::StrCat(child_dir, "/b"), "bar").ok());

std::vector<std::string> collected_paths;
const absl::Status status =
YieldFiles(root_dir, CollectPathsCallback(&collected_paths));
EXPECT_TRUE(status.ok());
EXPECT_THAT(collected_paths, testing::SizeIs(2));
}

} // namespace

} // namespace fuzzing
Loading