Tabulation fix + potential misaligned read fix

This commit is contained in:
Nemoumbra 2024-08-11 20:20:07 +03:00
parent 169736dff6
commit b794532a8e
2 changed files with 13 additions and 11 deletions

View file

@ -1219,8 +1219,9 @@ static void parsePrxLibInfo(const u8* ptr, u32 headerSize) {
// The lib info prefix looks like {'\', 'y', 'r', '=', '`', 'c', '`', '0'} (Big Endian) // The lib info prefix looks like {'\', 'y', 'r', '=', '`', 'c', '`', '0'} (Big Endian)
const u64_le lib_info_prefix = 0x306063603D72795C; const u64_le lib_info_prefix = 0x306063603D72795C;
auto lib_info_ptr = reinterpret_cast<const u64_le*>(ptr);
if (*lib_info_ptr != lib_info_prefix) { // 'ptr' can potentially be misaligned here so let's use a memcmp instead of dereferencing 8 bytes at 'ptr'
if (memcmp(ptr, &lib_info_prefix, 8) != 0) {
// That's very wrong! // That's very wrong!
WARN_LOG(Log::sceModule, "~SCE module, unexpected header (not an error)"); WARN_LOG(Log::sceModule, "~SCE module, unexpected header (not an error)");
return; return;
@ -1236,13 +1237,14 @@ static void parsePrxLibInfo(const u8* ptr, u32 headerSize) {
} }
nameBuffer[12] = '\0'; nameBuffer[12] = '\0';
u8 versionBuffer[8] = "?.?.?.?"; u8 versionBuffer[7 + 1] = "?.?.?.?";
for (int i = 0; i < 4; ++i, ++ptr) { for (int i = 0; i < 4; ++i, ++ptr) {
u8 symbol = *ptr - 0x14u; u8 symbol = *ptr - 0x14u;
if (isprint(symbol)) { if (isprint(symbol)) {
versionBuffer[2 * i] = symbol; versionBuffer[2 * i] = symbol;
} }
} }
// The null byte is already in its place, no need to assign it manually
INFO_LOG(Log::sceModule, "~SCE module: Lib-PSP %s (SDK %s)", nameBuffer, versionBuffer); INFO_LOG(Log::sceModule, "~SCE module: Lib-PSP %s (SDK %s)", nameBuffer, versionBuffer);
} }

View file

@ -61,7 +61,7 @@
#define IDD_GEDBG_TAB_MATRICES 255 #define IDD_GEDBG_TAB_MATRICES 255
#define IDD_GEDBG_STEPCOUNT 256 #define IDD_GEDBG_STEPCOUNT 256
#define IDD_CPUWATCH 257 #define IDD_CPUWATCH 257
#define IDD_EDITSYMBOLS 258 #define IDD_EDITSYMBOLS 258
#define IDC_STOPGO 1001 #define IDC_STOPGO 1001
#define IDC_ADDRESS 1002 #define IDC_ADDRESS 1002
@ -123,12 +123,12 @@
#define IDC_SHOWOFFSETS 1200 #define IDC_SHOWOFFSETS 1200
#define IDC_GEDBG_PRIMCOUNTER 1201 #define IDC_GEDBG_PRIMCOUNTER 1201
#define IDC_BUTTON_SEARCH 1204 #define IDC_BUTTON_SEARCH 1204
#define IDC_EDITSYMBOLS_SCAN 1205 #define IDC_EDITSYMBOLS_SCAN 1205
#define IDC_EDITSYMBOLS_REMOVE 1206 #define IDC_EDITSYMBOLS_REMOVE 1206
#define IDC_EDITSYMBOLS_ADDRESS 1207 #define IDC_EDITSYMBOLS_ADDRESS 1207
#define IDC_EDITSYMBOLS_SIZE 1208 #define IDC_EDITSYMBOLS_SIZE 1208
#define IDC_EDITSYMBOLS_OK 1209 #define IDC_EDITSYMBOLS_OK 1209
#define IDC_EDITSYMBOLS_CANCEL 1210 #define IDC_EDITSYMBOLS_CANCEL 1210
#define ID_FILE_EXIT 40000 #define ID_FILE_EXIT 40000
#define ID_DEBUG_SAVEMAPFILE 40001 #define ID_DEBUG_SAVEMAPFILE 40001
@ -354,7 +354,7 @@
#define IDC_DISASM_FMT_INT 40233 #define IDC_DISASM_FMT_INT 40233
#define IDC_DISASM_FMT_FLOAT 40234 #define IDC_DISASM_FMT_FLOAT 40234
#define IDC_DISASM_FMT_STR 40235 #define IDC_DISASM_FMT_STR 40235
#define ID_DISASM_EDITSYMBOLS 40236 #define ID_DISASM_EDITSYMBOLS 40236
// Dummy option to let the buffered rendering hotkey cycle through all the options. // Dummy option to let the buffered rendering hotkey cycle through all the options.