From cfe9424ba92c735613723ab18427d091f825de34 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Fri, 2 May 2025 10:41:35 +0200 Subject: [PATCH] rm: Fix regression from b278710 The forbidden() function only checks if we are trying to remove one of the . .. or / directories that are forbidden by POSIX, and it should not fail when it cannot stat a target, because that check is done later considering if -r, -f and -i were used or not. If the stat fails we can be sure that is not / and thus it is not a forbidden target. --- rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm.c b/rm.c index fd13b22..3adfc8c 100644 --- a/rm.c +++ b/rm.c @@ -33,7 +33,7 @@ forbidden(char *path, struct stat *root) } if (stat(path, &st) < 0) - eprintf("stat argument '%s':", path); + return 0; if (st.st_dev == root->st_dev && st.st_ino == root->st_ino) { if (!w2) weprintf("\"/\" may not be removed\n");