Explorar el Código

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

Tal Aloni hace 8 años
padre
commit
ee55b59a2f
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      SMBLibrary/Server/Helpers/NTFileSystemHelper.cs

+ 2 - 2
SMBLibrary/Server/Helpers/NTFileSystemHelper.cs

@@ -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;