diff --git a/libraries/libstratosphere/source/fs/fs_save_data_management.cpp b/libraries/libstratosphere/source/fs/fs_save_data_management.cpp index 63d72e769..c9335a9ea 100644 --- a/libraries/libstratosphere/source/fs/fs_save_data_management.cpp +++ b/libraries/libstratosphere/source/fs/fs_save_data_management.cpp @@ -89,9 +89,8 @@ namespace ams::fs { Result DeleteSystemSaveData(SaveDataSpaceId space_id, SystemSaveDataId id, UserId user_id) { const auto attribute = SaveDataAttribute::Make(ncm::InvalidProgramId, SaveDataType::System, user_id, id); - /* TODO: Libnx binding for DeleteSaveDataFileSystemBySaveDataAttribute */ - AMS_UNUSED(space_id, attribute); - AMS_ABORT(); + static_assert(sizeof(attribute) == sizeof(::FsSaveDataAttribute)); + return fsDeleteSaveDataFileSystemBySaveDataAttribute(static_cast<::FsSaveDataSpaceId>(space_id), reinterpret_cast(std::addressof(attribute))); } Result GetSaveDataFlags(u32 *out, SaveDataId id) { diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.hpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.hpp index 6ffea3a6c..fce94f2b0 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.hpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_impl.hpp @@ -26,6 +26,10 @@ namespace ams::sprofile::srv { ProfileManager *m_manager; public: ProfileImporterImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ } + + ~ProfileImporterImpl() { + m_manager->CloseProfileImporter(); + } public: Result ImportProfile(const sprofile::srv::ProfileDataForImportData &import); Result Commit(); diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.cpp index f414d5666..2ca8d0ea1 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.cpp @@ -151,6 +151,16 @@ namespace ams::sprofile::srv { return ResultSuccess(); } + void ProfileManager::CloseProfileImporter() { + /* Acquire locks. */ + std::scoped_lock lk1(m_profile_importer_mutex); + std::scoped_lock lk2(m_general_mutex); + std::scoped_lock lk3(m_fs_mutex); + + /* Close our importer. */ + m_profile_importer = util::nullopt; + } + Result ProfileManager::ImportProfile(const sprofile::srv::ProfileDataForImportData &import) { /* Acquire locks. */ std::scoped_lock lk1(m_profile_importer_mutex); @@ -165,6 +175,8 @@ namespace ams::sprofile::srv { /* Check that the metadata we're importing has a valid hash. */ { crypto::Md5Generator md5; + md5.Initialize(); + md5.Update(std::addressof(import.header), sizeof(import.header)); md5.Update(std::addressof(import.data), sizeof(import.data) - sizeof(import.data.entries[0]) * (util::size(import.data.entries) - std::min(import.data.num_entries, util::size(import.data.entries)))); @@ -258,6 +270,8 @@ namespace ams::sprofile::srv { /* Check that the metadata we're importing has a valid hash. */ { crypto::Md5Generator md5; + md5.Initialize(); + md5.Update(std::addressof(import.header), sizeof(import.header)); md5.Update(std::addressof(import.metadata), sizeof(import.metadata)); md5.Update(std::addressof(import.profile_urls), sizeof(import.profile_urls[0]) * std::min(import.metadata.num_entries, util::size(import.metadata.entries))); diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.hpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.hpp index 8e7b1e689..df976637e 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.hpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_manager.hpp @@ -50,6 +50,8 @@ namespace ams::sprofile::srv { Result ResetSaveData(); Result OpenProfileImporter(); + void CloseProfileImporter(); + Result ImportProfile(const sprofile::srv::ProfileDataForImportData &data); Result Commit(); Result ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &data); diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp index fad4893d0..67778a01a 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.cpp @@ -74,6 +74,7 @@ namespace ams::sprofile::srv { return ResultSuccess(); } + Result ServiceForBgAgent::IsUpdateNeeded(sf::Out out, Identifier revision_key) { /* Load primary metadata. */ bool loaded_metadata = true; diff --git a/libraries/libvapours/source/crypto/impl/crypto_md5_impl.cpp b/libraries/libvapours/source/crypto/impl/crypto_md5_impl.cpp index 5289a3581..6b98c384d 100644 --- a/libraries/libvapours/source/crypto/impl/crypto_md5_impl.cpp +++ b/libraries/libvapours/source/crypto/impl/crypto_md5_impl.cpp @@ -149,7 +149,7 @@ namespace ams::crypto::impl { /* Copy in any leftover data. */ if (const auto left = size % BlockSize; left > 0) { - std::memcpy(m_y, cur_block, size); + std::memcpy(m_y, cur_block, left); } }