NTFileSystemAdapter: Bugfix: FILE_OPEN_IF was not handled properly if the file exists

This commit is contained in:
Tal Aloni 2017-05-18 23:50:08 +03:00
parent dae8a6b19e
commit 340f55c26e

View file

@ -157,6 +157,20 @@ namespace SMBLibrary
else
{
fileStatus = FileStatus.FILE_EXISTS;
if (createDisposition == CreateDisposition.FILE_OPEN_IF)
{
if (entry.IsDirectory && forceFile)
{
return NTStatus.STATUS_FILE_IS_A_DIRECTORY;
}
if (!entry.IsDirectory && forceDirectory)
{
return NTStatus.STATUS_OBJECT_PATH_INVALID;
}
}
else
{
if (!requestedWriteAccess)
{
return NTStatus.STATUS_ACCESS_DENIED;
@ -186,7 +200,7 @@ namespace SMBLibrary
{
m_fileSystem.Delete(path);
}
catch(Exception ex)
catch (Exception ex)
{
NTStatus status = ToNTStatus(ex);
Log(Severity.Verbose, "CreateFile: Error deleting '{0}'. {1}.", path, status);
@ -216,6 +230,7 @@ namespace SMBLibrary
}
}
}
}
else
{
return NTStatus.STATUS_INVALID_PARAMETER;