summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorGlenn L McGrath2003-04-21 10:07:48 +0000
committerGlenn L McGrath2003-04-21 10:07:48 +0000
commit35a5b08eee997593e4e852a6b48fc4b2bb4904e6 (patch)
tree3bc2901d47c9d99de0d46dde758a4006bf1c39e8 /archival
parent6f9a0d4bbb0774822f7e19e59c21f4cbfd7e490e (diff)
downloadbusybox-35a5b08eee997593e4e852a6b48fc4b2bb4904e6.zip
busybox-35a5b08eee997593e4e852a6b48fc4b2bb4904e6.tar.gz
unlink() an existing file, before opening it, simply truncating can
cause nasty problems if overwriting glibc, spotted by waldi.
Diffstat (limited to 'archival')
-rw-r--r--archival/tar.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c
index c39d578..23af9ff 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -472,7 +472,8 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
tbInfo.tarFd = fileno(stdout);
tbInfo.verboseFlag = verboseFlag ? 2 : 0;
} else {
- tbInfo.tarFd = open(tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ unlink(tarName);
+ tbInfo.tarFd = open(tarName, O_WRONLY | O_CREAT | O_EXCL, 0644);
tbInfo.verboseFlag = verboseFlag ? 1 : 0;
}