mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 06:51:17 +01:00
Merge pull request #6148 from leoetlino/null-bug
NANDImporter: Construct strings correctly
This commit is contained in:
commit
91dac03c45
@ -122,10 +122,7 @@ void NANDImporter::FindSuperblock()
|
|||||||
|
|
||||||
std::string NANDImporter::GetPath(const NANDFSTEntry& entry, const std::string& parent_path)
|
std::string NANDImporter::GetPath(const NANDFSTEntry& entry, const std::string& parent_path)
|
||||||
{
|
{
|
||||||
std::string name(reinterpret_cast<const char*>(&entry.name), sizeof(NANDFSTEntry::name));
|
std::string name(entry.name, strnlen(entry.name, sizeof(NANDFSTEntry::name)));
|
||||||
// Get rid of any extra null characters
|
|
||||||
while (name.back() == '\0')
|
|
||||||
name.pop_back();
|
|
||||||
|
|
||||||
if (name.front() == '/' || parent_path.back() == '/')
|
if (name.front() == '/' || parent_path.back() == '/')
|
||||||
return parent_path + name;
|
return parent_path + name;
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct NANDFSTEntry
|
struct NANDFSTEntry
|
||||||
{
|
{
|
||||||
u8 name[12];
|
char name[12];
|
||||||
u8 mode; // 0x0C
|
u8 mode; // 0x0C
|
||||||
u8 attr; // 0x0D
|
u8 attr; // 0x0D
|
||||||
u16 sub; // 0x0E
|
u16 sub; // 0x0E
|
||||||
|
Loading…
x
Reference in New Issue
Block a user