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))
This commit is contained in:
parent
4cd2d525e3
commit
8f1f433834
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user