Return if the FIRM payloads filesize is different than expected

This commit is contained in:
Aurora Wright 2017-06-02 15:55:08 +02:00 committed by TuxSH
parent 47369c8f5e
commit ba3740a77a
3 changed files with 7 additions and 6 deletions

View File

@ -423,17 +423,19 @@ static __attribute__((noinline)) bool inRange(u32 as, u32 ae, u32 bs, u32 be)
return false;
}
bool checkFirmPayload(void)
bool checkFirmPayload(u32 payloadSize)
{
if(memcmp(firm->magic, "FIRM", 4) != 0 || firm->arm9Entry == NULL) //Allow for the ARM11 entrypoint to be zero in which case nothing is done on the ARM11 side
return false;
bool arm9EpFound = false,
arm11EpFound = false;
u32 size = 0x200;
for(u32 i = 0; i < 4; i++)
size += firm->section[i].size;
bool arm9EpFound = false,
arm11EpFound = false;
if(size != payloadSize) return false;
for(u32 i = 0; i < 4; i++)
{

View File

@ -33,6 +33,5 @@ u32 patchTwlFirm(u32 firmVersion, bool loadFromStorage, bool doUnitinfoPatch);
u32 patchAgbFirm(bool loadFromStorage, bool doUnitinfoPatch);
u32 patch1x2xNativeAndSafeFirm(bool enableExceptionHandlers);
bool checkFirmPayload(void);
bool checkFirmPayload(u32 payloadSize);
void launchFirm(int argc, char **argv);

View File

@ -161,7 +161,7 @@ void loadPayload(u32 pressed, const char *payloadPath)
payloadSize = fileRead(firm, path, maxPayloadSize);
if(payloadSize <= 0x200 || !checkFirmPayload()) return;
if(payloadSize <= 0x200 || !checkFirmPayload(payloadSize)) return;
writeConfig(true);