From 7b6e3dfbb05f4dea30d6d91f1f6345b3d66ed9b7 Mon Sep 17 00:00:00 2001 From: cui Date: Tue, 24 Mar 2026 00:28:51 +0800 Subject: [PATCH] Fix ReadlinkSlow buffer when lstat reports zero size (#6948) When the symlink target length from lstat was 0, the code resized the buffer using status.size() instead of buffer_size, so the first allocation stayed empty instead of using MinBufferSize. Align the resize with the buffer_size path used for readlinkat. --- common/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/filesystem.cpp b/common/filesystem.cpp index dce5d7b75fc6..904beb2c5db0 100644 --- a/common/filesystem.cpp +++ b/common/filesystem.cpp @@ -643,7 +643,7 @@ auto DirRef::ReadlinkSlow(const std::filesystem::path& path) if (buffer_size == 0) { buffer_size = MinBufferSize; } - large_buffer.resize(status.size()); + large_buffer.resize(buffer_size); ssize_t result = readlinkat(dfd_, path.c_str(), large_buffer.data(), large_buffer.size()); if (result == -1) {