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 a possible UAF #669

Merged
merged 2 commits into from
Jul 9, 2024
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
6 changes: 6 additions & 0 deletions src/raft/uv_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@

if (rv != 0 && *segments != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to the PR strictly but what does rv != 0 mean here @cole-miller. It is set in the above loop and it is overwritten every iteration so rv here is the return code of the last entry that we process, right? We are ignoring the return codes of all the entries but this one, is that sound?

Copy link
Contributor

@cole-miller cole-miller Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key is lines 64-72, if we get one nonzero return code from UvSnapshotInfoAppendIfMatch or uvSegmentInfoAppendIfMatch then we skip processing the rest of the files in the list. You're right, I wasn't reading closely enough, those lines don't work as intended because of uv_fs_scandir_next just above.

raft_free(*segments);
*segments = NULL;

Check warning on line 103 in src/raft/uv_list.c

View check run for this annotation

Codecov / codecov/patch

src/raft/uv_list.c#L103

Added line #L103 was not covered by tests
}

if (rv != 0 && *snapshots != NULL) {
raft_free(*snapshots);
*snapshots = NULL;

Check warning on line 108 in src/raft/uv_list.c

View check run for this annotation

Codecov / codecov/patch

src/raft/uv_list.c#L108

Added line #L108 was not covered by tests
}

if (*snapshots != NULL) {
Expand Down
Loading