summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-06-19 05:29:57 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-06-19 05:29:57 +0000
commit96ebd91d6cb0229ae940d3e2970eb145a183fb93 (patch)
tree4153427470fa2765d92507f4f731d962d553e661 /llvm/lib/Support
parent42908c7ac9955c80e8550ed3749f4446461ed5d8 (diff)
downloadbcm5719-llvm-96ebd91d6cb0229ae940d3e2970eb145a183fb93.tar.gz
bcm5719-llvm-96ebd91d6cb0229ae940d3e2970eb145a183fb93.zip
[Support/PathV2] Fix out of bounds access in identify_magic when the file is empty.
llvm-svn: 158704
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/PathV2.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index e2a69a650db..46571c049f1 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -744,6 +744,8 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
/// @brief Identify the magic in magic.
file_magic identify_magic(StringRef magic) {
+ if (magic.size() < 4)
+ return file_magic::unknown;
switch ((unsigned char)magic[0]) {
case 0xDE: // 0x0B17C0DE = BC wraper
if (magic[1] == (char)0xC0 && magic[2] == (char)0x17 &&
OpenPOWER on IntegriCloud