From cc5b5c15ac670eead9d6e87ad06ea61fdb0832c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 7 May 2017 16:16:19 +0200 Subject: [PATCH 1/2] IOS/ES: Fix a ticket validity check --- Source/Core/Core/IOS/ES/Formats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 831488d2df..2e823bdc80 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -239,7 +239,7 @@ void TicketReader::SetBytes(std::vector&& bytes) bool TicketReader::IsValid() const { - return m_bytes.size() % sizeof(Ticket) == 0; + return !m_bytes.empty() && m_bytes.size() % sizeof(Ticket) == 0; } void TicketReader::DoState(PointerWrap& p) From 3cdb8fd2975fb7604aeb8c447fdfb732e541d158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 7 May 2017 16:20:41 +0200 Subject: [PATCH 2/2] IOS/ES: Fix DeleteTitle to not use CNANDContentManager * CNANDContentManager does things that are absolutely useless. In particular, it parses the ticket, the TMD, reads contents, etc. when we only need to remove the title directory. * This means it will fail if the ticket cannot be found, when that should not be the case. * This also obviously caused DeleteTitle to be incredibly inefficient. * We are already removing the title directory later in the function, as CNANDContentManager does not even delete titles correctly. DeleteTitle != DeleteTitleContents. --- Source/Core/Core/IOS/ES/TitleManagement.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index 9975816a14..2de0ab7c40 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -317,17 +317,16 @@ IPCCommandResult ES::DeleteTitle(const IOCtlVRequest& request) return GetDefaultReply(ES_EINVAL); const std::string title_dir = Common::GetTitlePath(title_id, Common::FROM_SESSION_ROOT); - if (!File::IsDirectory(title_dir) || - !DiscIO::CNANDContentManager::Access().RemoveTitle(title_id, Common::FROM_SESSION_ROOT)) - { + if (!File::IsDirectory(title_dir)) return GetDefaultReply(FS_ENOENT); - } if (!File::DeleteDirRecursively(title_dir)) { ERROR_LOG(IOS_ES, "DeleteTitle: Failed to delete title directory: %s", title_dir.c_str()); return GetDefaultReply(FS_EACCESS); } + // XXX: ugly, but until we drop CNANDContentManager everywhere, this is going to be needed. + DiscIO::CNANDContentManager::Access().ClearCache(); return GetDefaultReply(IPC_SUCCESS); }