Fixed rare crash when accessing library import by name
The library name index may only be 8-bits.
This bug was not present in the previous implementation due to a bitmask
(0xFF) - see
ea99ba8e3b/src/xenia/kernel/util/xex2.cc (L272)
This commit is contained in:
parent
16c97189dd
commit
7e4fdf7669
|
@ -260,10 +260,12 @@ bool XexModule::Load(const std::string& name, const std::string& path,
|
|||
auto libraries_ptr = reinterpret_cast<uint8_t*>(opt_import_header) +
|
||||
opt_import_header->string_table_size + 12;
|
||||
uint32_t library_offset = 0;
|
||||
for (uint32_t i = 0; i < opt_import_header->library_count; i++) {
|
||||
uint32_t library_count = opt_import_header->library_count;
|
||||
for (uint32_t i = 0; i < library_count; i++) {
|
||||
auto library =
|
||||
reinterpret_cast<xex2_import_library*>(libraries_ptr + library_offset);
|
||||
SetupLibraryImports(string_table[library->name_index], library);
|
||||
SetupLibraryImports(string_table[library->name_index % library_count],
|
||||
library);
|
||||
library_offset += library->size;
|
||||
}
|
||||
|
||||
|
|
|
@ -475,10 +475,11 @@ void UserModule::Dump() {
|
|||
reinterpret_cast<const uint8_t*>(opt_import_libraries) +
|
||||
opt_import_libraries->string_table_size + 12;
|
||||
uint32_t library_offset = 0;
|
||||
for (uint32_t l = 0; l < opt_import_libraries->library_count; l++) {
|
||||
uint32_t library_count = opt_import_libraries->library_count;
|
||||
for (uint32_t l = 0; l < library_count; l++) {
|
||||
auto library = reinterpret_cast<const xex2_import_library*>(
|
||||
libraries + library_offset);
|
||||
auto name = string_table[library->name_index];
|
||||
auto name = string_table[library->name_index % library_count];
|
||||
sb.AppendFormat(" %s - %d imports\n", name,
|
||||
(uint16_t)library->count);
|
||||
|
||||
|
|
|
@ -285,7 +285,8 @@ int xe_xex2_read_header(const uint8_t* addr, const size_t length,
|
|||
library->version.value = src_library->version.value;
|
||||
library->min_version.value = src_library->version_min.value;
|
||||
|
||||
std::strncpy(library->name, string_table[src_library->name_index],
|
||||
std::strncpy(library->name,
|
||||
string_table[src_library->name_index % count],
|
||||
xe::countof(library->name));
|
||||
|
||||
library->record_count = src_library->count;
|
||||
|
|
Loading…
Reference in New Issue