[llvm] r183666 - Fix an out of bounds array access.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jun 10 08:22:19 PDT 2013
Author: rafael
Date: Mon Jun 10 10:22:18 2013
New Revision: 183666
URL: http://llvm.org/viewvc/llvm-project?rev=183666&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Support/Path.cpp
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=183666&r1=183665&r2=183666&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Mon Jun 10 10:22:18 2013
@@ -58,11 +58,12 @@ sys::identifyFileType(const char *Magic,
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;
More information about the llvm-commits
mailing list