Fix garbage data in converted CIAs

Partial fix for #587
This commit is contained in:
d0k3 2020-03-09 22:52:45 +01:00
parent da28c0ef40
commit 182f1ebe43

View File

@ -188,12 +188,13 @@ u32 LoadNcchMeta(CiaMeta* meta, const char* path, u64 offset) {
} }
u32 LoadTmdFile(TitleMetaData* tmd, const char* path) { u32 LoadTmdFile(TitleMetaData* tmd, const char* path) {
UINT br; // first part (TMD only) (we need to read the content count first)
if ((fvx_qread(path, tmd, 0, TMD_SIZE_MIN, NULL) != FR_OK) ||
// full TMD file (ValidateTmd(tmd) != 0))
if ((fvx_qread(path, tmd, 0, TMD_SIZE_MAX, &br) != FR_OK) || return 1;
(br < TMD_SIZE_MIN) || (ValidateTmd(tmd) != 0) ||
(br < TMD_SIZE_N(getbe16(tmd->content_count)))) // second part (read full size)
if (fvx_qread(path, tmd, 0, TMD_SIZE_N(getbe16(tmd->content_count)), NULL) != FR_OK)
return 1; return 1;
return 0; return 0;