prevent directory traversal from index paths
This commit is contained in:
parent
450e0aba27
commit
68afc2511a
|
@ -185,6 +185,16 @@ void FATStorage::LoadIndex()
|
|||
for (const auto& [key, val] : DirIndex)
|
||||
{
|
||||
std::string path = val.Path;
|
||||
|
||||
if ((path.find("/./") != std::string::npos) ||
|
||||
(path.find("/../") != std::string::npos) ||
|
||||
(path.substr(0,2) == "./") ||
|
||||
(path.substr(0,3) == "../"))
|
||||
{
|
||||
removelist.push_back(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
int sep = path.rfind('/');
|
||||
if (sep == std::string::npos) continue;
|
||||
|
||||
|
@ -205,6 +215,16 @@ void FATStorage::LoadIndex()
|
|||
for (const auto& [key, val] : FileIndex)
|
||||
{
|
||||
std::string path = val.Path;
|
||||
|
||||
if ((path.find("/./") != std::string::npos) ||
|
||||
(path.find("/../") != std::string::npos) ||
|
||||
(path.substr(0,2) == "./") ||
|
||||
(path.substr(0,3) == "../"))
|
||||
{
|
||||
removelist.push_back(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
int sep = path.rfind('/');
|
||||
if (sep == std::string::npos) continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue