mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-22 20:06:40 +00:00
fs: fix out of bounds access when parsing directory paths
This commit is contained in:
parent
596a0f2551
commit
6f54ab5716
2 changed files with 5 additions and 6 deletions
|
@ -101,10 +101,9 @@ namespace ams::fs {
|
||||||
s32 i;
|
s32 i;
|
||||||
for (i = m_position; m_buffer[i] != StringTraits::DirectorySeparator; ++i) {
|
for (i = m_position; m_buffer[i] != StringTraits::DirectorySeparator; ++i) {
|
||||||
if (m_buffer[i] == StringTraits::NullTerminator) {
|
if (m_buffer[i] == StringTraits::NullTerminator) {
|
||||||
if (i == m_position) {
|
char * const ret = (i != m_position) ? m_buffer + m_position : nullptr;
|
||||||
m_position = -1;
|
m_position = -1;
|
||||||
return nullptr;
|
return ret;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ namespace ams::fssystem {
|
||||||
private:
|
private:
|
||||||
Result ResolveFullPath(fs::Path *out, const fs::Path &path) {
|
Result ResolveFullPath(fs::Path *out, const fs::Path &path) {
|
||||||
if (path.IsMatchHead(m_before_dir.GetString(), m_before_dir.GetLength())) {
|
if (path.IsMatchHead(m_before_dir.GetString(), m_before_dir.GetLength())) {
|
||||||
R_TRY(out->InitializeWithFormat("%s%s", m_after_dir.GetString(), path.GetString() + m_before_dir.GetLength()));
|
R_TRY(out->Initialize(m_after_dir));
|
||||||
R_TRY(out->Normalize(fs::PathFlags{}));
|
R_TRY(out->AppendChild(path));
|
||||||
} else {
|
} else {
|
||||||
R_TRY(out->Initialize(path));
|
R_TRY(out->Initialize(path));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue