From 91468ede5b0fd079f80d0c8f5cd4b1c6cc654a8b Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 9 Sep 2018 19:56:38 +0800 Subject: [PATCH] [fac] Fixed bug where incorrect sizes FAC contentid & saveownerid lists generated. --- lib/libhac/source/FileSystemAccessControlBinary.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/libhac/source/FileSystemAccessControlBinary.cpp b/lib/libhac/source/FileSystemAccessControlBinary.cpp index c8c7e94..18f08af 100644 --- a/lib/libhac/source/FileSystemAccessControlBinary.cpp +++ b/lib/libhac/source/FileSystemAccessControlBinary.cpp @@ -41,9 +41,17 @@ void nn::hac::FileSystemAccessControlBinary::toBytes() } content, savedata; content.offset = (uint32_t)align(sizeof(sFacHeader), fac::kSectionAlignSize); - content.size = (uint32_t)(sizeof(uint32_t) + mContentOwnerIdList.size() * sizeof(uint64_t)); + if (mContentOwnerIdList.size() > 0) + content.size = (uint32_t)(sizeof(uint32_t) + mContentOwnerIdList.size() * sizeof(uint64_t)); + else + content.size = 0; + savedata.offset = (uint32_t)(content.offset + (content.size > 0 ? align(content.size, fac::kSectionAlignSize) : 0)); - savedata.size = (uint32_t)(sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), fac::kSectionAlignSize) + mSaveDataOwnerIdList.size() * sizeof(uint64_t)); + if (mSaveDataOwnerIdList.size() > 0) + savedata.size = (uint32_t)(sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), fac::kSectionAlignSize) + mSaveDataOwnerIdList.size() * sizeof(uint64_t)); + else + savedata.size = 0; + // get total size size_t total_size = _MAX(_MAX(content.offset + content.size, savedata.offset + savedata.size), align(sizeof(sFacHeader), fac::kSectionAlignSize));