Permalink
Browse files

Fixes a second crash reported by Kim Gwan Yeong.

  • Loading branch information...
JusticeRage committed Jun 27, 2017
1 parent 2800b67 commit 9d68586397ecc0f2ce5727ce8e80a2e6254c5239
Showing with 15 additions and 4 deletions.
  1. +9 −2 manape/resources.cpp
  2. +6 −2 manape/section.cpp
@@ -343,7 +343,7 @@ DECLSPEC pbitmap Resource::interpret_as()
memcpy(&dib_header_size, &(res->data[0]), sizeof(boost::uint32_t)); // DIB header size is located at offset 0.
memcpy(&bit_count, &(res->data[14]), sizeof(boost::uint16_t));
memcpy(&colors_used, &(res->data[32]), sizeof(boost::uint32_t));


if (colors_used == 0 && bit_count != 32 && bit_count != 24) {
colors_used = 1 << bit_count;
@@ -494,7 +494,14 @@ DECLSPEC pversion_info Resource::interpret_as()
// In the file, the language information is an int stored into a "unicode" string.
ss << std::hex << current_structure->Key;
ss >> language;
res->Language = *nt::translate_to_flag((language >> 16) & 0xFFFF, nt::LANG_IDS);
if (!ss.fail()) {
res->Language = *nt::translate_to_flag((language >> 16) & 0xFFFF, nt::LANG_IDS);
}
else
{
PRINT_WARNING << "A language ID could not be translated (" << std::hex << res->Language << ")!" << std::endl;
res->Language = "UNKNOWN";
}

bytes_read = ftell(f) - bytes_read;
if (current_structure->Length < bytes_read)
@@ -48,10 +48,14 @@ Section::Section(const image_section_header& header,
{
std::stringstream ss;
unsigned int index;
ss << header.Name + 1; // Skip the trailing "/"
ss << _name.substr(1); // Skip the trailing "/"
ss >> index;

if (index >= coff_string_table.size()) {
if (ss.fail()) {
PRINT_WARNING << "Found a non-integer index of the COFF string table (" << _name << "). This PE "
"was almost certainly manually crafted." << std::endl;
}
else if (index >= coff_string_table.size()) {
PRINT_WARNING << "Tried to read outside the COFF string table to get the name of section " << _name << "!" << std::endl;
}
else {

0 comments on commit 9d68586

Please sign in to comment.