From 27becdec9752edd598336b0d1d22162dcccafcca Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 6 Sep 2021 15:45:13 +0300 Subject: [PATCH] TAR: Allow to use save_directory with a buffer not 512-bytes aligned --- rpcs3/Loader/TAR.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index 5705c69013..df69d017df 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -306,6 +306,8 @@ std::vector tar_object::save_directory(const std::string& src_dir, std::vect { fs::file fd(target_path); + const u64 old_size2 = init.size(); + if (func) { // Use custom function for file saving if provided @@ -319,13 +321,12 @@ std::vector tar_object::save_directory(const std::string& src_dir, std::vect } else { - const u64 old_size2 = init.size(); init.resize(init.size() + stat.size); ensure(fd.read(init.data() + old_size2, stat.size) == stat.size); } // Align - init.resize(utils::align(init.size(), 512)); + init.resize(old_size2 + utils::align(init.size() - old_size2, 512)); fd.close(); fs::utime(target_path, stat.atime, stat.mtime);