mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-27 21:04:32 +00:00
Merge pull request #445 from kohnakagawa/fix/escape_all_strings
Update mbedtls version to fix #395.
This commit is contained in:
commit
a81ee63e11
@ -45,8 +45,8 @@ set(LIBRANG_SOURCE_DIR "${SOURCE_DIR}")
|
||||
|
||||
# mbed TLS
|
||||
# --------
|
||||
set(MBED_TLS_VERSION 2.16.6)
|
||||
set(MBED_TLS_SHA256 SHA256=b9a8c5af8cd32e62b985dc8cb43397e4230a5437ce2ce3b7fedb2c6dc65115d8)
|
||||
set(MBED_TLS_VERSION 2.23.0)
|
||||
set(MBED_TLS_SHA256 SHA256=bbf9c3cc6b7603f2f15bbba7badcf6cf188a9d5aaa63c4df2d61213f459c2f5f)
|
||||
set(MBED_TLS_URL "${THIRD_PARTY_DIRECTORY}/mbedtls-${MBED_TLS_VERSION}.zip" CACHE STRING "URL to MbedTLS")
|
||||
set(MBED_TLS_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/mbed_tls")
|
||||
|
||||
@ -102,7 +102,6 @@ set(mbedtls_src_crypto
|
||||
"${MBEDTLS_SOURCE_DIR}/library/md2.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/md4.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/md5.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/md_wrap.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/memory_buffer_alloc.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/net_sockets.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/nist_kw.c"
|
||||
@ -129,6 +128,19 @@ set(mbedtls_src_crypto
|
||||
"${MBEDTLS_SOURCE_DIR}/library/version.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/version_features.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/xtea.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/aria.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/chacha20.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/chachapoly.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/hkdf.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/nist_kw.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/platform_util.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/poly1305.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/psa_crypto.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/psa_crypto_se.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/psa_crypto_slot_management.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/psa_crypto_storage.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/psa_its_file.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/rsa_internal.c"
|
||||
)
|
||||
|
||||
set(mbedtls_src_x509
|
||||
@ -153,6 +165,7 @@ set(mbedtls_src_tls
|
||||
"${MBEDTLS_SOURCE_DIR}/library/ssl_srv.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/ssl_ticket.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/ssl_tls.c"
|
||||
"${MBEDTLS_SOURCE_DIR}/library/ssl_msg.c"
|
||||
)
|
||||
|
||||
#set_source_files_properties("${MBEDTLS_SOURCE_DIR}/library/bignum.c" PROPERTIES COMPILE_FLAGS -Wno-overlength-strings)
|
||||
|
@ -24,6 +24,26 @@
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
|
||||
std::string to_hex(const char c) {
|
||||
std::stringstream ss;
|
||||
ss << std::setfill('0') << std::setw(2) << std::hex << (0xff & (unsigned int)c);
|
||||
return std::string("\\x") + ss.str();
|
||||
}
|
||||
|
||||
std::string escape_non_ascii(const std::string& s) {
|
||||
std::string result;
|
||||
const auto len = s.size();
|
||||
for (auto i = 0u; i < len; i++) {
|
||||
const auto c = s[i];
|
||||
if (c < 32 || c >= 127) {
|
||||
result += to_hex(c);
|
||||
} else {
|
||||
result.push_back(c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
json to_json(const Object& v) {
|
||||
JsonVisitor visitor;
|
||||
visitor(v);
|
||||
@ -264,7 +284,7 @@ void JsonVisitor::visit(const DataDirectory& data_directory) {
|
||||
this->node_["size"] = data_directory.size();
|
||||
this->node_["type"] = to_string(data_directory.type());
|
||||
if (data_directory.has_section()) {
|
||||
this->node_["section"] = data_directory.section().name();
|
||||
this->node_["section"] = escape_non_ascii(data_directory.section().name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +300,7 @@ void JsonVisitor::visit(const Section& section) {
|
||||
types.emplace_back(to_string(t));
|
||||
}
|
||||
|
||||
this->node_["name"] = section.name();
|
||||
this->node_["name"] = escape_non_ascii(section.name());
|
||||
this->node_["pointerto_relocation"] = section.pointerto_relocation();
|
||||
this->node_["pointerto_line_numbers"] = section.pointerto_line_numbers();
|
||||
this->node_["numberof_relocations"] = section.numberof_relocations();
|
||||
@ -322,12 +342,12 @@ void JsonVisitor::visit(const Export& export_) {
|
||||
this->node_["major_version"] = export_.major_version();
|
||||
this->node_["minor_version"] = export_.minor_version();
|
||||
this->node_["ordinal_base"] = export_.ordinal_base();
|
||||
this->node_["name"] = export_.name();
|
||||
this->node_["name"] = escape_non_ascii(export_.name());
|
||||
this->node_["entries"] = entries;
|
||||
}
|
||||
|
||||
void JsonVisitor::visit(const ExportEntry& export_entry) {
|
||||
this->node_["name"] = export_entry.name();
|
||||
this->node_["name"] = escape_non_ascii(export_entry.name());
|
||||
this->node_["ordinal"] = export_entry.ordinal();
|
||||
this->node_["address"] = export_entry.address();
|
||||
this->node_["is_extern"] = export_entry.is_extern();
|
||||
@ -355,7 +375,7 @@ void JsonVisitor::visit(const TLS& tls) {
|
||||
}
|
||||
|
||||
if (tls.has_section()) {
|
||||
this->node_["section"] = tls.section().name();
|
||||
this->node_["section"] = escape_non_ascii(tls.section().name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,7 +430,7 @@ void JsonVisitor::visit(const CodeViewPDB& cvpdb) {
|
||||
this->visit(static_cast<const CodeView&>(cvpdb));
|
||||
this->node_["signature"] = cvpdb.signature();
|
||||
this->node_["age"] = cvpdb.age();
|
||||
this->node_["filename"] = cvpdb.filename();
|
||||
this->node_["filename"] = escape_non_ascii(cvpdb.filename());
|
||||
}
|
||||
|
||||
void JsonVisitor::visit(const Import& import) {
|
||||
@ -501,7 +521,7 @@ void JsonVisitor::visit(const ResourceDirectory& resource_directory) {
|
||||
void JsonVisitor::visit(const ResourcesManager& resources_manager) {
|
||||
if (resources_manager.has_manifest()) {
|
||||
try {
|
||||
this->node_["manifest"] = resources_manager.manifest();
|
||||
this->node_["manifest"] = escape_non_ascii(resources_manager.manifest()) ;
|
||||
} catch (const LIEF::exception& e) {
|
||||
LOG(WARNING) << e.what();
|
||||
}
|
||||
|
BIN
third-party/mbedtls-2.16.6.zip
vendored
BIN
third-party/mbedtls-2.16.6.zip
vendored
Binary file not shown.
BIN
third-party/mbedtls-2.23.0.zip
vendored
Normal file
BIN
third-party/mbedtls-2.23.0.zip
vendored
Normal file
Binary file not shown.
BIN
third-party/mbedtls-2.6.0.zip
vendored
BIN
third-party/mbedtls-2.6.0.zip
vendored
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user