Compare all 4 bytes of the header.

llvm-svn: 134427
This commit is contained in:
Rafael Espindola 2011-07-05 18:41:47 +00:00
parent b7c0083878
commit 00aae24a08
1 changed files with 3 additions and 2 deletions

View File

@ -309,8 +309,9 @@ COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec)
if (!checkSize(Data, ec, 0x3c + 8)) return;
HeaderStart += *reinterpret_cast<const ulittle32_t *>(base() + 0x3c);
// Check the PE header. ("PE\0\0")
if (StringRef(reinterpret_cast<const char *>(base() + HeaderStart), 4)
!= "PE\0\0") {
StringRef Actual(reinterpret_cast<const char *>(base() + HeaderStart), 4);
StringRef Expcted("PE\0\0", 4);
if (Actual != Expcted) {
ec = object_error::parse_failed;
return;
}