diff --git a/Source/Core/Core/HW/WiiSave.cpp b/Source/Core/Core/HW/WiiSave.cpp index 0814448df0..bb7494ef5e 100644 --- a/Source/Core/Core/HW/WiiSave.cpp +++ b/Source/Core/Core/HW/WiiSave.cpp @@ -105,10 +105,12 @@ struct FileHDR u8 permissions; u8 attrib; u8 type; // (1=file, 2=directory) - std::array name; + std::array name; + std::array padding; std::array iv; std::array unk; }; +static_assert(sizeof(FileHDR) == 0x80, "FileHDR has an incorrect size"); #pragma pack(pop) class Storage @@ -370,7 +372,8 @@ public: if (type != SaveFile::Type::Directory && type != SaveFile::Type::File) return {}; save_file.type = type; - save_file.path = file_hdr.name.data(); + save_file.path = + std::string{file_hdr.name.data(), strnlen(file_hdr.name.data(), file_hdr.name.size())}; if (type == SaveFile::Type::File) { const u32 rounded_size = Common::AlignUp(file_hdr.size, BLOCK_SZ); @@ -419,7 +422,7 @@ public: file_hdr.permissions = save_file.mode; file_hdr.attrib = save_file.attributes; file_hdr.type = static_cast(save_file.type); - if (save_file.path.length() > 0x44) + if (save_file.path.length() > file_hdr.name.size()) return false; std::strncpy(file_hdr.name.data(), save_file.path.data(), file_hdr.name.size());