[llvm-commits] [llvm] r158704 - /llvm/trunk/lib/Support/PathV2.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Mon Jun 18 22:29:57 PDT 2012
Author: mspencer
Date: Tue Jun 19 00:29:57 2012
New Revision: 158704
URL: http://llvm.org/viewvc/llvm-project?rev=158704&view=rev
Log:
[Support/PathV2] Fix out of bounds access in identify_magic when the file is empty.
Modified:
llvm/trunk/lib/Support/PathV2.cpp
Modified: llvm/trunk/lib/Support/PathV2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=158704&r1=158703&r2=158704&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Tue Jun 19 00:29:57 2012
@@ -744,6 +744,8 @@
/// @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 &&
More information about the llvm-commits
mailing list