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: 183666
This commit is contained in:
parent
693b4750d1
commit
548e9d4834
|
@ -58,11 +58,12 @@ sys::identifyFileType(const char *Magic, unsigned Length) {
|
|||
break;
|
||||
|
||||
case '\177':
|
||||
if (Magic[1] == 'E' && Magic[2] == 'L' && Magic[3] == 'F') {
|
||||
if (Length >= 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 (Length >= 18 && Magic[high] == 0)
|
||||
if (Magic[high] == 0)
|
||||
switch (Magic[low]) {
|
||||
default: break;
|
||||
case 1: return ELF_Relocatable_FileType;
|
||||
|
|
Loading…
Reference in New Issue