Turns out, if we have a compression layer in patches, we can just ignore the one from the base NCA.
bktrIsBlockWithinIndirectStorageRange() still needs to be updated.
ncaStorageSetPatchOriginalSubStorage: allow Patch title version to be equal to the Base title version (e.g. sparse titles).
ncaStorageGetHashTargetExtents: actually set proper storage extents.
bktrGetTreeNodeEntryIndex: fix index lookup algorithm.
bktrStorageNodeFind: fix binary search.
bktrVisitorMoveNext / bktrVisitorMovePrevious: fix integer overflows.
* Check for sparse layers in nsp_dumper and xml_generator PoCs before attempting to initialize content-type-specific contexts.
* system_title_dumper now builds.
* gamecardCloseStorageArea() no longer returns prematurely on application exit.
* Fix section size for sparse sections in ncaInitializeFsSectionContext().
* Fix ncaFsSectionValidateHashDataBoundaries().
* Implement bktrInitializeIndirectStorage() and bktrInitializeAesCtrExStorage().
* Made ncaGenerateEncryptedFsSectionBlock() entirely private. There's no point in keeping it public.
* Moved NCA FS section context initialization into its own function, ncaInitializeFsSectionContext().
* Hash data boundaries are now checked while initializing each NCA FS section context, using ncaFsSectionValidateHashDataBoundaries(). Both ncaValidateHierarchicalSha256Offsets() and ncaValidateHierarchicalIntegrityOffsets() have been removed.
* Improved hash region access detection in _ncaReadFsSection() by implementing ncaFsSectionCheckHashRegionAccess().
* ncaGetFsSectionHashTargetProperties() is now used in pfs.c, romfs.c and bktr.c to retrieve the properties from the target hash layer.
* Updated sanity checks in pfsInitializeContext(), romfsInitializeContext() and bktrInitializeContext().
* keysGetKeyAndValueFromFile() is now thread-safe -- may be useful for people reusing code from nxdumptool. The dynamic buffer allocated by __getline() must be freed by the caller. Furthermore, this fixes an out-of-bounds issue while writing data to the static array that was being used with fgets().
* Empty lines are now considered failures.
* keysGetKeyAndValueFromFile() now validates the value string and converts it to lowercase as well.
* Adjusted the example regex in the description for keysGetKeyAndValueFromFile() to accurately match what the function actually does.
* Added helper macros to keysReadKeysFromFile().