diff options
author | Brad King <brad.king@kitware.com> | 2020-07-07 17:39:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-08 19:49:56 (GMT) |
commit | eaa420e99c86cb700f37fd21420ab86adeed798f (patch) | |
tree | 1aef06fb7ca3e936b98dd32324de0ae6a70a934a | |
parent | 09ff1cb650a8084fce51f0005c446ea9215890d3 (diff) | |
download | CMake-eaa420e99c86cb700f37fd21420ab86adeed798f.zip CMake-eaa420e99c86cb700f37fd21420ab86adeed798f.tar.gz CMake-eaa420e99c86cb700f37fd21420ab86adeed798f.tar.bz2 |
cmGeneratedFileStream: Use random temporary file extension by default
Avoid collisions with project-specified files named with `.tmp`.
Issue: #20873
-rw-r--r-- | Source/cmGeneratedFileStream.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 119067e..345f0ba 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -129,7 +129,9 @@ void cmGeneratedFileStreamBase::Open(std::string const& name) if (!this->TempExt.empty()) { this->TempName += this->TempExt; } else { - this->TempName += "tmp"; + char buf[64]; + sprintf(buf, "tmp%05x", cmSystemTools::RandomSeed() & 0xFFFFF); + this->TempName += buf; } // Make sure the temporary file that will be used is not present. |