mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 20:12:02 +00:00
fs::absolute
This commit is contained in:
parent
018d52d71f
commit
add5970b5f
@ -30,13 +30,12 @@ RegionsHierarchiesDataProvider::RegionsHierarchiesDataProvider(const std::string
|
||||
void RegionsHierarchiesDataProvider::discoverFilesWithCustomHierarchies()
|
||||
{
|
||||
std::string basename = fs::path(path).stem();
|
||||
fs::path dir_path = fs::absolute(path).parent_path();
|
||||
|
||||
Poco::Path dir_path = Poco::Path(path).absolute().parent();
|
||||
|
||||
Poco::DirectoryIterator dir_end;
|
||||
for (Poco::DirectoryIterator dir_it(dir_path); dir_it != dir_end; ++dir_it)
|
||||
fs::directory_iterator dir_end;
|
||||
for (fs::directory_iterator dir_it(dir_path); dir_it != dir_end; ++dir_it)
|
||||
{
|
||||
std::string candidate_basename = dir_it.path().getBaseName();
|
||||
std::string candidate_basename = dir_it->path().stem();
|
||||
|
||||
if (candidate_basename.starts_with(basename)
|
||||
&& (candidate_basename.size() > basename.size() + 1)
|
||||
|
@ -652,8 +652,8 @@ void Fetcher::downloadBaseOrProjectionPartToDisk(
|
||||
|
||||
/// File must be inside "absolute_part_path" directory.
|
||||
/// Otherwise malicious ClickHouse replica may force us to write to arbitrary path.
|
||||
String absolute_file_path = Poco::Path(part_download_path + file_name).absolute().toString();
|
||||
if (!startsWith(absolute_file_path, Poco::Path(part_download_path).absolute().toString()))
|
||||
String absolute_file_path = fs::absolute(fs::path(part_download_path) / file_name);
|
||||
if (!startsWith(absolute_file_path, fs::absolute(part_download_path).string()))
|
||||
throw Exception("File path (" + absolute_file_path + ") doesn't appear to be inside part path (" + part_download_path + ")."
|
||||
" This may happen if we are trying to download part from malicious replica or logical error.",
|
||||
ErrorCodes::INSECURE_PATH);
|
||||
|
Loading…
Reference in New Issue
Block a user