From fd312abedd437bc22b34da65eb1ff42dadce7388 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Oct 2018 01:35:38 -0400 Subject: submission_package: Move NCA reading code to its own function This too, is completely separate behavior from what is in the constructor, so we can move this to its own isolated function to keep everything self-contained. --- src/core/file_sys/submission_package.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/file_sys/submission_package.h') diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index e85a2b76e..7c7cebf33 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -59,6 +59,8 @@ protected: bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; private: + void ReadNCAs(const std::vector& files); + VirtualFile file; bool extracted; -- cgit v1.2.3 From ccf0a9cb381cad75878c79b962ac61ded0466d08 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Oct 2018 01:43:34 -0400 Subject: submission_package: Move ExeFS and RomFS initialization to its own function Like the other two bits of factored out code, this can also be put within its own function. We can also modify the code so that it accepts a const reference to a std::vector of files, this way, we can deduplicate the file retrieval. Now the constructor for NSP isn't a combination of multiple behaviors in one spot. It's nice and separate. --- src/core/file_sys/submission_package.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/file_sys/submission_package.h') diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index 7c7cebf33..297821522 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -59,6 +59,7 @@ protected: bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; private: + void InitializeExeFSAndRomFS(const std::vector& files); void ReadNCAs(const std::vector& files); VirtualFile file; -- cgit v1.2.3 From 37ee05f7c0f1fa8d94317e92795016e91f1bdfa6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Oct 2018 01:47:32 -0400 Subject: submission_package: Ensure the 'extracted' member variable is always initialized If an error occurs when constructing the PartitionFilesystem instance, the constructor would be exited early, which wouldn't initialize the extracted data member, making it possible for other code to perform an uninitialized read by calling the public IsExtractedType() member function. This prevents that. --- src/core/file_sys/submission_package.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/file_sys/submission_package.h') diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index 297821522..da3dc5e9f 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -64,7 +64,7 @@ private: VirtualFile file; - bool extracted; + bool extracted = false; Loader::ResultStatus status; std::map program_status; -- cgit v1.2.3