diff options
| author | zousar <[email protected]> | 2026-03-17 23:44:19 -0600 |
|---|---|---|
| committer | zousar <[email protected]> | 2026-03-17 23:44:19 -0600 |
| commit | ed8ef5f2ded97d34f0d1bd4a45eca65a73e75eb5 (patch) | |
| tree | 3db6aa71914289a45b7c449fe735d044f8af893d | |
| parent | Add tests for long path handling in project store (diff) | |
| download | zen-ed8ef5f2ded97d34f0d1bd4a45eca65a73e75eb5.tar.xz zen-ed8ef5f2ded97d34f0d1bd4a45eca65a73e75eb5.zip | |
Fix long path handling for project store
| -rw-r--r-- | src/zenremotestore/projectstore/remoteprojectstore.cpp | 1 | ||||
| -rw-r--r-- | src/zenserver/storage/projectstore/httpprojectstore.cpp | 11 | ||||
| -rw-r--r-- | src/zenstore/projectstore.cpp | 6 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp index 8ba2397ff..1a9dc10ef 100644 --- a/src/zenremotestore/projectstore/remoteprojectstore.cpp +++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp @@ -488,6 +488,7 @@ namespace remotestore_impl { { std::string_view ServerPath = View["serverpath"sv].AsString(); std::filesystem::path FilePath = (Project.RootDir / ServerPath).make_preferred(); + MakeSafeAbsolutePathInPlace(FilePath); if (!IsFile(FilePath)) { remotestore_impl::ReportMessage( diff --git a/src/zenserver/storage/projectstore/httpprojectstore.cpp b/src/zenserver/storage/projectstore/httpprojectstore.cpp index 38a121b37..3bde082e5 100644 --- a/src/zenserver/storage/projectstore/httpprojectstore.cpp +++ b/src/zenserver/storage/projectstore/httpprojectstore.cpp @@ -3161,8 +3161,10 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req) continue; } - std::error_code Ec; - const std::filesystem::path FilePath = std::filesystem::canonical(Project->RootDir / ServerPath, Ec); + std::error_code Ec; + // Long paths require MakeSafeAbsolutePath otherwise canonical will yield an error code + const std::filesystem::path FilePath = + std::filesystem::canonical(MakeSafeAbsolutePath(Project->RootDir / ServerPath), Ec); if (Ec) { @@ -3183,7 +3185,10 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req) } BasicFile DataFile; - DataFile.Open(FilePath, BasicFile::Mode::kRead, Ec); + // Even after calling MakeSafeAbsolutePath on the input to canonical, we will fail to read + // long paths for the output of canonical unless we make them safe here again, because the + // output of canonical will have stripped things like the leading characters to handle long paths + DataFile.Open(MakeSafeAbsolutePath(FilePath), BasicFile::Mode::kRead, Ec); if (Ec) { diff --git a/src/zenstore/projectstore.cpp b/src/zenstore/projectstore.cpp index 03086b473..54fd2b789 100644 --- a/src/zenstore/projectstore.cpp +++ b/src/zenstore/projectstore.cpp @@ -2403,8 +2403,9 @@ ProjectStore::Oplog::IterateChunks(const std::filesystem::path& P { return; } - size_t FileChunkIndex = FileChunkIndexes[ChunkIndex]; - const std::filesystem::path& FilePath = FileChunkPaths[ChunkIndex]; + size_t FileChunkIndex = FileChunkIndexes[ChunkIndex]; + std::filesystem::path FilePath = FileChunkPaths[ChunkIndex]; + MakeSafeAbsolutePathInPlace(FilePath); try { IoBuffer Payload = IoBufferBuilder::MakeFromFile(FilePath); @@ -2519,6 +2520,7 @@ ProjectStore::Oplog::FindChunk(const std::filesystem::path& ProjectRootDir, cons if (auto FileIt = m_FileMap.find(ChunkId); FileIt != m_FileMap.end()) { std::filesystem::path FilePath = ProjectRootDir / FileIt->second.ServerPath; + MakeSafeAbsolutePathInPlace(FilePath); OplogLock.ReleaseNow(); |