From 581e591070f934a5e04b5e13e60f67579703992c Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Sun, 11 May 2025 22:24:34 +0200 Subject: [PATCH] arm9: fix loadDeliverArg bug --- arm9/source/deliver_arg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arm9/source/deliver_arg.c b/arm9/source/deliver_arg.c index 9d91eff2..0ef1a596 100644 --- a/arm9/source/deliver_arg.c +++ b/arm9/source/deliver_arg.c @@ -71,7 +71,7 @@ u8 *loadDeliverArg(void) bool hasMagic = memcmp(tlnc, "TLNC", 4) == 0; u8 crcLen = tlnc[5]; u16 crc = *(u16 *)(tlnc + 6); - if (!hasMagic || crcLen <= 248 || crc != crc16(tlnc + 8, crcLen, 0xFFFF)) + if (!hasMagic || (8 + crcLen) > 0x100 || crc != crc16(tlnc + 8, crcLen, 0xFFFF)) memset(tlnc, 0, 0x100); memset(deliverArg + 0x400, 0, 0xC00); @@ -141,6 +141,8 @@ static bool configureHomebrewAutobootCtr(u8 *deliverArg) return false; u8 memtype = configData.autobootCtrAppmemtype; + // autobootCtrAppmemtype already checked, but it doesn't hurt to check again + memtype = memtype >= 5 ? 0 : memtype; deliverArg[0x400] = ISN3DS ? appmemtypesN3ds[memtype] : appmemtypesO3ds[memtype]; // Determine whether to load from the SD card or from NAND. We don't support gamecards for this