mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge pull request #57029 from ClickHouse/fix_DatabaseFilesystem_path_validation
Fix file path validation for DatabaseFileSystem
This commit is contained in:
commit
a1bb31525a
@ -40,13 +40,15 @@ DatabaseFilesystem::DatabaseFilesystem(const String & name_, const String & path
|
||||
{
|
||||
path = user_files_path / path;
|
||||
}
|
||||
else if (!is_local && !pathStartsWith(fs::path(path), user_files_path))
|
||||
|
||||
path = fs::absolute(path).lexically_normal();
|
||||
|
||||
if (!is_local && !pathStartsWith(fs::path(path), user_files_path))
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
||||
"Path must be inside user-files path: {}", user_files_path.string());
|
||||
}
|
||||
|
||||
path = fs::absolute(path).lexically_normal();
|
||||
if (!fs::exists(path))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path does not exist: {}", path);
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
create database db_filesystem ENGINE=Filesystem('/etc'); -- { serverError BAD_ARGUMENTS }
|
||||
create database db_filesystem ENGINE=Filesystem('../../../../../../../../etc'); -- { serverError BAD_ARGUMENTS }
|
Loading…
Reference in New Issue
Block a user