mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-01 07:30:33 +00:00
[Support/PathV2] Fix out of bounds access in identify_magic when the file is empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158704 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bde801b2a7
commit
b51c8e9bb5
@ -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 &&
|
||||
|
Loading…
Reference in New Issue
Block a user