mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 03:23:01 +02:00
Port r183666 to identify_magic.
It will be tested in the next commit which moves another user to identify_magic. Original message: Fix an out of bounds array access. We were looking at Magic[5] without checking Length. Since this path would not return unless Length >= 18 anyway, just move the >= 18 check up. llvm-svn: 183753
This commit is contained in:
parent
aa92ec8890
commit
440e3e004e
@ -788,11 +788,12 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
|
||||
break;
|
||||
|
||||
case '\177':
|
||||
if (Magic[1] == 'E' && Magic[2] == 'L' && Magic[3] == 'F') {
|
||||
if (Magic.size() >= 18 && Magic[1] == 'E' && Magic[2] == 'L' &&
|
||||
Magic[3] == 'F') {
|
||||
bool Data2MSB = Magic[5] == 2;
|
||||
unsigned high = Data2MSB ? 16 : 17;
|
||||
unsigned low = Data2MSB ? 17 : 16;
|
||||
if (Magic.size() >= 18 && Magic[high] == 0)
|
||||
if (Magic[high] == 0)
|
||||
switch (Magic[low]) {
|
||||
default: break;
|
||||
case 1: return file_magic::elf_relocatable;
|
||||
|
Loading…
Reference in New Issue
Block a user