[*] harden dir traversal for removal

This commit is contained in:
Reece Wilson 2024-03-13 10:08:38 +00:00
parent a80f6091c5
commit dbd2ec78b3
2 changed files with 8 additions and 1 deletions

View File

@ -76,7 +76,7 @@ namespace Aurora::IO::FS
pNext->fileName.insert(pNext->fileName.begin(), curSubDir.begin(), curSubDir.end());
}
if (pNext->bExistsDirectory)
if (pNext->bExistsDirectory && !pNext->bSymLink)
{
nextLevel.push_back(pNext->fileName + "/");
nextLevel2.push_back(pNext->fileName + "/");

View File

@ -378,6 +378,13 @@ namespace Aurora::IO::FS
{
return true;
}
else if (errno == ENOTDIR)
{
if (::unlink(pathExpanded.c_str()) == 0)
{
return true;
}
}
}
if (S_ISREG(s.st_mode))