Better handling of Transaction2SetFileInformation requests

This commit is contained in:
Tal Aloni 2016-12-27 02:39:25 +02:00
parent 0eecde7152
commit 2da05e979b

View file

@ -281,6 +281,8 @@ namespace SMBLibrary.Server
return null;
}
OpenedFileObject fileObject = state.GetOpenedFileObject(subcommand.FID);
Transaction2SetFileInformationResponse response = new Transaction2SetFileInformationResponse();
switch (subcommand.InformationLevel)
{
@ -370,8 +372,13 @@ namespace SMBLibrary.Server
return null;
}
if (fileObject.Stream != null)
{
fileObject.Stream.Close();
}
try
{
System.Diagnostics.Debug.Print("[{0}] NTCreate: Deleting file '{1}'", DateTime.Now.ToString("HH:mm:ss:ffff"), openedFilePath);
share.FileSystem.Delete(openedFilePath);
}
catch (IOException)
@ -395,9 +402,7 @@ namespace SMBLibrary.Server
ulong allocationSize = ((SetFileAllocationInfo)subcommand.SetInfo).AllocationSize;
try
{
Stream stream = share.FileSystem.OpenFile(openedFilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
stream.SetLength((long)allocationSize);
stream.Close();
fileObject.Stream.SetLength((long)allocationSize);
}
catch (IOException)
{
@ -414,9 +419,7 @@ namespace SMBLibrary.Server
ulong endOfFile = ((SetFileEndOfFileInfo)subcommand.SetInfo).EndOfFile;
try
{
Stream stream = share.FileSystem.OpenFile(openedFilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
stream.SetLength((long)endOfFile);
stream.Close();
fileObject.Stream.SetLength((long)endOfFile);
}
catch (IOException)
{