From a05cc1ff564fc2450b72efb12a0b3e244d3e615c Mon Sep 17 00:00:00 2001 From: d0k3 Date: Mon, 3 Sep 2018 22:55:37 +0200 Subject: [PATCH] Properly verify CFA NCCHs Also fixes NCSD verification --- arm9/source/utils/gameutil.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arm9/source/utils/gameutil.c b/arm9/source/utils/gameutil.c index 3f2ce9f..e3fde81 100644 --- a/arm9/source/utils/gameutil.c +++ b/arm9/source/utils/gameutil.c @@ -318,11 +318,18 @@ u32 VerifyNcchFile(const char* path, u32 offset, u32 size) { return 1; fvx_lseek(&file, offset); - if (GetNcchHeaders(&ncch, &exthdr, NULL, &file) != 0) { + if (GetNcchHeaders(&ncch, NULL, NULL, &file) != 0) { if (!offset) ShowPrompt(false, "%s\nError: Not a NCCH file", pathstr); fvx_close(&file); return 1; } + + fvx_lseek(&file, offset); + if (ncch.size_exthdr && (GetNcchHeaders(&ncch, &exthdr, NULL, &file) != 0)) { + if (!offset) ShowPrompt(false, "%s\nError: Missing ExtHeader", pathstr); + fvx_close(&file); + return 1; + } fvx_lseek(&file, offset); if (ncch.size_exefs && (GetNcchHeaders(&ncch, NULL, &exefs, &file) != 0)) {