From: Glenn L McGrath Date: Mon, 21 Apr 2003 10:07:48 +0000 (-0000) Subject: unlink() an existing file, before opening it, simply truncating can X-Git-Tag: 1_00_pre1~111 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=35a5b08eee997593e4e852a6b48fc4b2bb4904e6;p=oweals%2Fbusybox.git unlink() an existing file, before opening it, simply truncating can cause nasty problems if overwriting glibc, spotted by waldi. --- diff --git a/archival/tar.c b/archival/tar.c index c39d5787f..23af9ffa3 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; }