Browse Source

Bug 1999: Failure when SFTP server resolves "." path to an empty string

https://winscp.net/tracker/1999
(cherry picked from commit 5ab9308af08aeaa3cb06d4bc70bc86fabf4726ab)

Source commit: 59f1f053d3fcdd7a9ab271798d845ef0ec62c9a7
Martin Prikryl 4 years ago
parent
commit
0526ba04e9
1 changed files with 5 additions and 0 deletions
  1. 5 0
      source/core/SftpFileSystem.cpp

+ 5 - 0
source/core/SftpFileSystem.cpp

@@ -2923,6 +2923,11 @@ UnicodeString __fastcall TSFTPFileSystem::GetHomeDirectory()
   if (FHomeDirectory.IsEmpty())
   if (FHomeDirectory.IsEmpty())
   {
   {
     FHomeDirectory = RealPath(L".");
     FHomeDirectory = RealPath(L".");
+    // Prevent infinite recursion when the server is broken
+    if (FHomeDirectory.IsEmpty())
+    {
+      FHomeDirectory = ROOTDIRECTORY;
+    }
   }
   }
   return FHomeDirectory;
   return FHomeDirectory;
 }
 }