rm: fix path parsing for dot/dotdot protection #11005
Open
naoNao89 wants to merge 1 commit intouutils:mainfrom
Open
rm: fix path parsing for dot/dotdot protection #11005naoNao89 wants to merge 1 commit intouutils:mainfrom
naoNao89 wants to merge 1 commit intouutils:mainfrom
Conversation
27615a2 to
048da76
Compare
|
GNU testsuite comparison: |
048da76 to
5c3b675
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
b06619a to
ca8c88d
Compare
|
GNU testsuite comparison: |
ca8c88d to
fcba02e
Compare
Fix path parsing in rm to properly detect and reject attempts to remove the current directory (.) and parent directory (..), matching GNU rm behavior. Changes: - Rewrite path_is_current_or_parent_directory() to handle trailing slashes, multiple slashes, and mixed separator edge cases - Add is_dot_or_dotdot_bytes() helper for cross-platform path component parsing - Handle Windows backslash separators in addition to forward slashes - Add comprehensive regression tests for edge cases: * Multiple trailing slashes (dir///) * Mixed dot and dot-dot paths (./dir/., dir/sub/..) * Normal files containing dots (file.txt, .hidden) * Mixed valid and dot arguments * Windows-specific edge cases with backslashes * Symlink resolution to dot paths Fixes uutils#9749
fcba02e to
9f962fe
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Merging this PR will improve performance by 3.11%
Performance Changes
Comparing Footnotes
|
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.
Fix
rm -rf ./silently deleting contents. Improvespath_is_current_or_parent_directory()to properly detect paths like./,../,d/., etc.Added robust byte-level path parsing and comprehensive tests
Fixes #9749.
Future Work (maybe)
--preserve-root=allmount point detectionFTStraversal (safer directory walking)DS_EMPTY,DS_NONEMPTY)would require significant refactoring and are outside of PR