summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2013-02-19 18:57:53 +0000
committerDan Gohman <dan433584@gmail.com>2013-02-19 18:57:53 +0000
commit22954dbb7e9a8db1225c2ef891ee4905c22e0e00 (patch)
tree5964f06239bd968e32471804a0e872cbc552e2e8 /llvm/lib/Support
parent3fa275e6f76a5b7fc24c341a58aa10f8da987e92 (diff)
downloadbcm5719-llvm-22954dbb7e9a8db1225c2ef891ee4905c22e0e00.tar.gz
bcm5719-llvm-22954dbb7e9a8db1225c2ef891ee4905c22e0e00.zip
Don't trust st_size of a character device. This fixes using
/dev/stdin as an input when stdin is connected to a tty, for example. No test, because it's difficult to write a reasonably portable test for this. /dev/stdin isn't a character device when stdin is redirected from a file or connected to a pipe. llvm-svn: 175542
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/MemoryBuffer.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index 65b43322e66..b0a20853b5c 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -322,9 +322,9 @@ error_code MemoryBuffer::getOpenFile(int FD, const char *Filename,
return error_code(errno, posix_category());
}
- // If this is a named pipe, we can't trust the size. Create the memory
- // buffer by copying off the stream.
- if (S_ISFIFO(FileInfo.st_mode)) {
+ // 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)) {
return getMemoryBufferForStream(FD, Filename, result);
}
OpenPOWER on IntegriCloud