rm: fix path parsing for dot/dotdot protection #11005
Merged
Merged
Conversation
naoNao89
force-pushed
the
rm-dot-protection-9749
branch
2 times, most recently
from
February 18, 2026 04:32
27615a2 to
048da76
Compare
|
GNU testsuite comparison: |
naoNao89
force-pushed
the
rm-dot-protection-9749
branch
from
February 18, 2026 04:38
048da76 to
5c3b675
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
naoNao89
force-pushed
the
rm-dot-protection-9749
branch
from
February 18, 2026 08:46
b06619a to
ca8c88d
Compare
|
GNU testsuite comparison: |
naoNao89
force-pushed
the
rm-dot-protection-9749
branch
2 times, most recently
from
February 18, 2026 14:11
fcba02e to
9f962fe
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
Fixes uutils#9749: rm -rf ./ and variants silently delete current directory contents. The path_is_current_or_parent_directory() function did not match paths like "./" after clean_trailing_slashes() collapsed them. Rewrite the function to strip trailing separators, extract the last component, and check if it is "." or "..". Co-authored-by: naoNao89 <naoNao89@users.noreply.github.com>
sylvestre
force-pushed
the
rm-dot-protection-9749
branch
from
April 14, 2026 21:08
9f962fe to
cb45f75
Compare
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