aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/MemoryBuffer.cpp
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
commit2b49dec41bff103925d63b57f79b076daad4179e (patch)
treec6094ed05cb3606c39719b0585d8e92d92a78131 /lib/Support/MemoryBuffer.cpp
parent4fd4c91c40fa40ae4cd671b03056de8c3c961046 (diff)
downloadexternal_llvm-2b49dec41bff103925d63b57f79b076daad4179e.zip
external_llvm-2b49dec41bff103925d63b57f79b076daad4179e.tar.gz
external_llvm-2b49dec41bff103925d63b57f79b076daad4179e.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/MemoryBuffer.cpp')
-rw-r--r--lib/Support/MemoryBuffer.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 65b4332..b0a2085 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/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);
}