[llvm-commits] CVS: llvm/lib/System/Unix/Path.cpp

Reid Spencer reid at x10sys.com
Wed Dec 15 00:32:57 PST 2004



Changes in directory llvm/lib/System/Unix:

Path.cpp updated: 1.22 -> 1.23
---
Log message:

Fix a file overwrite bug in llvm-ar introduced by changes to 
createTemporaryFile semantics where it doesn't create a fully unique name
if the basename doesn't exist. This functionality is now optionally
provided by the boolean reuse_current parameter to createTemporaryFile and
makeUnique. The default values differ because of the way these functions
are used in LLVM.


---
Diffs of the changes:  (+4 -4)

Index: llvm/lib/System/Unix/Path.cpp
diff -u llvm/lib/System/Unix/Path.cpp:1.22 llvm/lib/System/Unix/Path.cpp:1.23
--- llvm/lib/System/Unix/Path.cpp:1.22	Tue Dec 14 19:50:13 2004
+++ llvm/lib/System/Unix/Path.cpp	Wed Dec 15 02:32:45 2004
@@ -481,13 +481,13 @@
 }
 
 bool
-Path::createTemporaryFile() {
+Path::createTemporaryFile(bool reuse_current) {
   // Make sure we're dealing with a file
   if (!isFile()) 
     return false;
 
   // Make this into a unique file name
-  makeUnique();
+  makeUnique( reuse_current );
 
   // create the file
   int outFile = ::open(path.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666);
@@ -600,8 +600,8 @@
 }
 
 void 
-Path::makeUnique() {
-  if (!exists())
+Path::makeUnique(bool reuse_current) {
+  if (reuse_current && !exists())
     return; // File doesn't exist already, just use it!
 
   // Append an XXXXXX pattern to the end of the file for use with mkstemp, 






More information about the llvm-commits mailing list