Skip to content

Commit

Permalink
Fix #693
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Apr 2, 2022
1 parent c2dc898 commit 3155174
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/PE/ResourcesParser.cpp
Expand Up @@ -472,17 +472,22 @@ ok_error_t ResourcesParser::parse_string(LangCodeItem& lci, BinaryStream& stream
/*
* Read the value
*/
LIEF_DEBUG("String.Value @0x{:x}", stream.pos());
if (auto res = stream.read_u16string()) {
if (res->size() + /* null char */ 1 != wValueLength) {
LIEF_INFO("String.Value.size() is different from wValueLength ({} / {})",
wValueLength, res->size() + 1);
if (wValueLength > 0) {
LIEF_DEBUG("String.Value @0x{:x}", stream.pos());
if (auto res = stream.read_u16string()) {
if (res->size() + /* null char */ 1 != wValueLength) {
LIEF_INFO("String.Value.size() is different from wValueLength ({} / {})",
wValueLength, res->size() + 1);
}
value = res->c_str(); // To remove trailling \0
std::string u8value = u16tou8(value);
LIEF_DEBUG("{}: {}", u8szKey, u8value);
lci.items_.emplace(szKey, value);
stream.align(sizeof(uint32_t));
}
value = res->c_str(); // To remove trailling \0
std::string u8value = u16tou8(value);
LIEF_DEBUG("{}: {}", u8szKey, u8value);
lci.items_.emplace(szKey, value);
stream.align(sizeof(uint32_t));
} else {

lci.items_.emplace(szKey, std::u16string());
}
} else {
LIEF_ERR("Can't read String.szKey");
Expand Down

0 comments on commit 3155174

Please sign in to comment.