1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Give script rmdir's directory entries a full path

For rmdir, TScript::CreateFileList (fltDirectories) creates a bare
TRemoteFile with only its name and type: no directory list and no full
file name. TWebDAVFileSystem::DeleteFile takes the path from
File->FullFileName, and TRemoteFile::GetFullFileName then dereferences the
null Directory. With WinSCP 6.5.7 a script doing

  mkdir /work/gone
  rmdir /work/gone

over WebDAV fails with "Invalid access to memory" in
TRemoteFileList::GetFullDirectory (from TWebDAVFileSystem::FilePath,
TTerminal::DoDeleteFile, TScript::RmDirProc).

The entry now carries its absolute path, resolved as TTerminal::DoDeleteFile
resolves the same name. Protocols that use the file name (SFTP, SCP, FTP)
are unaffected; WebDAV now deletes the directory.
This commit is contained in:
Eduardo Correia
2026-10-12 18:30:58 -03:00
committed by Martin Prikryl
parent d6dd4c7ec8
commit 8f67d22382

View File

@@ -587,6 +587,8 @@ TStrings * __fastcall TScript::CreateFileList(TScriptProcParams * Parameters, in
{
TRemoteFile * File = new TRemoteFile();
File->FileName = FileName;
// There is no listing to resolve the path from
File->FullFileName = FTerminal->AbsolutePath(FileName, true);
File->Type = FILETYPE_DIRECTORY;
Result->AddObject(FileName, File);
}