diff options
author | Dan Gohman <dan433584@gmail.com> | 2013-02-19 19:36:55 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2013-02-19 19:36:55 +0000 |
commit | a8eae3e35866329f2191a22a34421faa61448508 (patch) | |
tree | be18d822b6b88db40fa619a4f30dd3b693457a3a | |
parent | 2b49dec41bff103925d63b57f79b076daad4179e (diff) | |
download | external_llvm-a8eae3e35866329f2191a22a34421faa61448508.zip external_llvm-a8eae3e35866329f2191a22a34421faa61448508.tar.gz external_llvm-a8eae3e35866329f2191a22a34421faa61448508.tar.bz2 |
Whitelist files and block devices instead of blacklisting fifos and
character devices.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175549 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/MemoryBuffer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index b0a2085..0d5d4d7 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -322,9 +322,10 @@ error_code MemoryBuffer::getOpenFile(int FD, const char *Filename, return error_code(errno, posix_category()); } - // If this is a named pipe or character device, we can't trust the size. - // Create the memory buffer by copying off the stream. - if (S_ISFIFO(FileInfo.st_mode) || S_ISCHR(FileInfo.st_mode)) { + // If this not a file or a block device (e.g. it's a named pipe + // or character device), we can't trust the size. Create the memory + // buffer by copying off the stream. + if (!S_ISREG(FileInfo.st_mode) && !S_ISBLK(FileInfo.st_mode)) { return getMemoryBufferForStream(FD, Filename, result); } |