summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-07 05:20:05 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-07 05:20:05 +0000
commit5f9e301521a4c45ec49d0153c5dc81366da2681a (patch)
treef5c18e2ebee653d0e8238e6b2f716b636f0fadf3 /llvm/lib/System/Unix
parent814928fb32cbef22d174db32b3d3a5f533fd9e2e (diff)
downloadbcm5719-llvm-5f9e301521a4c45ec49d0153c5dc81366da2681a.tar.gz
bcm5719-llvm-5f9e301521a4c45ec49d0153c5dc81366da2681a.zip
Add a note about how the "isFile" check in Path::eraseFromDisk prevents
the erasure of non-file paths like /dev/null. llvm-svn: 29539
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Path.inc5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc
index 83885c31b0d..f79b2b2064a 100644
--- a/llvm/lib/System/Unix/Path.inc
+++ b/llvm/lib/System/Unix/Path.inc
@@ -569,6 +569,11 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
if (getFileStatus(Status, ErrStr))
return true;
+ // Note: this check catches strange situations. In all cases, LLVM should only
+ // be involved in the creation and deletion of regular files. This check
+ // ensures that what we're trying to erase is a regular file. It effectively
+ // prevents LLVM from erasing things like /dev/null, any block special file,
+ // or other things that aren't "regular" files.
if (Status.isFile) {
if (unlink(path.c_str()) != 0)
return GetErrno(path + ": can't destroy file", ErrStr);
OpenPOWER on IntegriCloud