diff options
author | Rob Landley <rob@landley.net> | 2020-01-28 21:49:52 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-01-28 21:49:52 -0600 |
commit | 70ab2dfb923e98fc1b0af27ec98efd0220fe6de6 (patch) | |
tree | 7ce4ac3b71e6c31a762956efa09a1bbcc89ac341 | |
parent | 3d4a1f6a0eccf8f910919c4605a3b17b9f5a1070 (diff) | |
download | toybox-70ab2dfb923e98fc1b0af27ec98efd0220fe6de6.tar.gz |
David Legault complained that dir/.* tells rm to delete dir/.. and we'd do it.
-rw-r--r-- | toys/posix/rm.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/toys/posix/rm.c b/toys/posix/rm.c index 2a6bc282..eec586c5 100644 --- a/toys/posix/rm.c +++ b/toys/posix/rm.c @@ -99,6 +99,11 @@ void rm_main(void) error_msg("rm /. if you mean it"); continue; } + // "rm dir/.*" can expand to include .. which generally isn't what you want + if (!strcmp("..", basename(*s))) { + error_msg("bad path %s", *s); + continue; + } // Files that already don't exist aren't errors for -f, so try a quick // unlink now to see if it succeeds or reports that it didn't exist. |