unlink() an existing file, before opening it, simply truncating can
cause nasty problems if overwriting glibc, spotted by waldi.
This commit is contained in:
parent
6f9a0d4bbb
commit
35a5b08eee
@ -472,7 +472,8 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
|
|||||||
tbInfo.tarFd = fileno(stdout);
|
tbInfo.tarFd = fileno(stdout);
|
||||||
tbInfo.verboseFlag = verboseFlag ? 2 : 0;
|
tbInfo.verboseFlag = verboseFlag ? 2 : 0;
|
||||||
} else {
|
} 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;
|
tbInfo.verboseFlag = verboseFlag ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user