summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/rmdir/rmdir.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/rmdir/rmdir.c b/bin/rmdir/rmdir.c
index 85dfde1..87167ec 100644
--- a/bin/rmdir/rmdir.c
+++ b/bin/rmdir/rmdir.c
@@ -103,9 +103,11 @@ rm_path(char *path)
*++p = '\0';
while ((p = strrchr(path, '/')) != NULL) {
/* Delete trailing slashes. */
- while (--p > path && *p == '/')
+ while (--p >= path && *p == '/')
;
*++p = '\0';
+ if (p == path)
+ break;
if (rmdir(path) < 0) {
warn("%s", path);
OpenPOWER on IntegriCloud