aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/posix/rm.c5
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.