Repository navigation
fix: a read must open the file that was listed - #32
Closed
petecleary wants to merge 2 commits into
Closed
petecleary wants to merge 2 commits into
petecleary wants to merge 2 commits into
Conversation
added 2 commits
November 28, 2026 22:12
… its checks Fails on this commit: on the Windows path each step is checked, then the file is opened by path, so a folder swapped for a link in between is followed.
The directory source records each listed file's device and inode, and the open handle must match them. This closes the gap in the step-by-step check used where there is no O_NOFOLLOW (Windows): a folder swapped for a link between the checks and the open.
Contributor
Author
|
This work continues in 0.8.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The directory-source part of the fix in moca-reader-typescript #50 and moca-reader-dotnet #34: a link swapped in after listing, at the file or at a folder on its path, is not followed.
Before: on POSIX this Reader already opened each folder and the file relative to the one before with
O_NOFOLLOW, and checked the open handle. Where there is noO_NOFOLLOW(Windows), it checked each step of the path withlstatand then opened the file by path, so a folder swapped for a link between the checks and the open was followed.Now: the directory source records each listed file's device and inode (
st_dev,st_ino; on Windows the volume and file index), and both read paths refuse an open file that is not the one listed.Test:
test_the_step_by_step_check_refuses_a_folder_swapped_after_the_checksdrives the Windows path (sys.platformpatched) and swapscontent/for a link to an outside folder just before the open. Added in the first commit, where it fails.Check (against moca-spec v0.7.0, this branch's pin):