summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-10-25 13:58:50 +0000
committerJim Meyering <jim@meyering.net>1998-10-25 13:58:50 +0000
commit9e630b86cb456b1551feed0f7e9ae75931a2af29 (patch)
tree7a0715b1b86353fe392b67125915c5b29509792b
parent2e19f14a91a4657734b43ebc1c9368062d297c80 (diff)
downloadcoreutils-9e630b86cb456b1551feed0f7e9ae75931a2af29.tar.gz
(remove_cwd_entries): Don't apply CLOSEDIR to a NULL
pointer. (provoke with `mkdir -m 0100 x; rm -rf x') Upon CLOSEDIR failure, set `status' to RM_ERROR, not RM_OK. (remove_dir): Return `status', rather than always RM_OK.
-rw-r--r--src/remove.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/remove.c b/src/remove.c
index 292282199..e35c1e378 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -575,12 +575,15 @@ remove_cwd_entries (const struct rm_options *x)
}
while (dirp == NULL);
- if (CLOSEDIR (dirp))
+ if (dirp)
{
- error (0, errno, "%s", full_filename ("."));
- status = RM_OK;
+ if (CLOSEDIR (dirp))
+ {
+ error (0, errno, "%s", full_filename ("."));
+ status = RM_ERROR;
+ }
+ dirp = NULL;
}
- dirp = NULL;
if (ht)
{
@@ -766,7 +769,7 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
return RM_ERROR;
}
- return RM_OK;
+ return status;
}
/* Remove the file or directory specified by FS after checking appropriate