瀏覽代碼

cmGeneratedFileStream: Use random temporary file extension by default

Avoid collisions with project-specified files named with `.tmp`.

Issue: #20873
Brad King 5 年之前
父節點
當前提交
eaa420e99c
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Source/cmGeneratedFileStream.cxx

+ 3 - 1
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.