Return STATUS_ACCESS_DENIED when writing to file that was opened for reading and vice versa

This commit is contained in:
Tal Aloni 2017-01-22 22:26:14 +02:00
parent 1679629b47
commit ee55b59a2f

View file

@ -274,7 +274,7 @@ namespace SMBLibrary.Server
}
else // File
{
if (stream == null)
if (stream == null || !stream.CanRead)
{
state.LogToServer(Severity.Debug, "ReadFile: Cannot read '{0}', Invalid Operation.", openFilePath);
return NTStatus.STATUS_ACCESS_DENIED;
@ -335,7 +335,7 @@ namespace SMBLibrary.Server
}
else // File
{
if (stream == null)
if (stream == null || !stream.CanWrite)
{
state.LogToServer(Severity.Debug, "WriteFile: Cannot write '{0}'. Invalid Operation.", openFilePath);
return NTStatus.STATUS_ACCESS_DENIED;