summaryrefslogtreecommitdiffstats
path: root/bin/rm
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2003-11-08 09:55:16 +0000
committerbde <bde@FreeBSD.org>2003-11-08 09:55:16 +0000
commit5b6accf9d94d507491925783053fec79d29d7f55 (patch)
treeed91b59919571c679347e43137d9ddef8d9d1b83 /bin/rm
parentb652116ae946f9f6b733455558cc0f8a35407ed2 (diff)
downloadFreeBSD-src-5b6accf9d94d507491925783053fec79d29d7f55.zip
FreeBSD-src-5b6accf9d94d507491925783053fec79d29d7f55.tar.gz
1. Fixed leakage of a file descriptor for every non-fatal failure in
rm_overwrite() (for rm -P). 2. Print the file name in the error message for (fatal) malloc() failures in rm_overwrite(). I first thought that malloc() failures should be non-fatal since they don't prevent proceeding the the next file, but making them non-fatal would normally give too much output for rm -Pr on a large tree in the unlikely event that even one occurs, since the malloc()ed amounts are usually the same. Just print the file name since the malloc()ed amounts are not always the same and it doesn't hurt to know where rm was when it quit. Submitted by: guido ((1) and original version of (2))
Diffstat (limited to 'bin/rm')
-rw-r--r--bin/rm/rm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index ea65d3b..7f8f230 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -384,7 +384,7 @@ rm_overwrite(char *file, struct stat *sbp)
goto err;
bsize = MAX(fsb.f_iosize, 1024);
if ((buf = malloc(bsize)) == NULL)
- err(1, "malloc");
+ err(1, "%s: malloc", file);
#define PASS(byte) { \
memset(buf, byte, bsize); \
@@ -409,6 +409,8 @@ rm_overwrite(char *file, struct stat *sbp)
err: eval = 1;
if (buf)
free(buf);
+ if (fd != -1)
+ close(fd);
warn("%s", file);
}
OpenPOWER on IntegriCloud