mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
Fix FIRM validation before boot
This commit is contained in:
parent
2387cb9e21
commit
fdb93b51f3
@ -71,12 +71,11 @@ u32 ValidateFirm(void* firm, u32 firm_size) {
|
||||
u32 valid_address[] = { FIRM_VALID_ADDRESS };
|
||||
FirmSectionHeader* section = header->sections + i;
|
||||
if (!section->size) continue;
|
||||
if (sha_cmp(section->hash, (u8*) firm + section->offset, section->size, SHA256_MODE) != 0) {
|
||||
if (sha_cmp(section->hash, ((u8*) firm) + section->offset, section->size, SHA256_MODE) != 0)
|
||||
return 1;
|
||||
}
|
||||
bool is_valid_address = false;
|
||||
for (u32 a = 0; a < sizeof(valid_address) / (2*sizeof(u32)); a++) {
|
||||
if ((valid_address[2*a] >= section->address) && (valid_address[(2*a)+1] <= section->address + section->size))
|
||||
if ((section->address >= valid_address[2*a]) && (section->address + section->size <= valid_address[(2*a)+1]))
|
||||
is_valid_address = true;
|
||||
}
|
||||
if (!is_valid_address) return 1;
|
||||
|
@ -1423,7 +1423,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
|
||||
ShowPrompt(false, "FIRM too big, can't launch"); // unlikely
|
||||
} else if (ShowUnlockSequence(3, "%s (%dkB)\nBoot FIRM via chainloader?", pathstr, firm_size / 1024)) {
|
||||
if ((FileGetData(curr_entry->path, TEMP_BUFFER, firm_size, 0) == firm_size) &&
|
||||
(ValidateFirm(TEMP_BUFFER, firm_size) != 0)) {
|
||||
(ValidateFirm(TEMP_BUFFER, firm_size) == 0)) {
|
||||
// fix the boot path first ("sdmc"/"nand" for Luma et al, hacky af)
|
||||
const char* bootpath = curr_entry->path;
|
||||
char fixpath[256] = { 0 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user